maratumba / boilerplate-angular-django-jwt-login Goto Github PK
View Code? Open in Web Editor NEWBoilerplate Django REST and Angular app with jwt login
License: MIT License
Boilerplate Django REST and Angular app with jwt login
License: MIT License
Nice boilerplate by the way and thank you for inspiring me on this but I realised that there is something there that is missing (interceptor). You validate for 403 and 401 if the request is the same as the refresh and for 403 if something else but you forgot to validate for a 401 in case the user token is no longer valid but the token is still refreshable (Google recommends a maximum of 200 days for refreshable tokens).
return next.handle(request).pipe(catchError(error => {
const isRefreshable = this.authService.isRefreshable();
if ( error instanceof HttpErrorResponse && (error.status === 401 || error.status === 403)
&& request.url === `${environment.apis.v1}/auth/token/refresh`) {
// We do another check to see if refresh token failed
// In this case we want to logout user and to redirect it to login page
// console.log('on your way out')
this.authService.logout();
return throwError(error);
}
else if (error instanceof HttpErrorResponse && error.status === 403) {
return this.handle403or401RefreshError(request, next);
} else if (error instanceof HttpErrorResponse && error.status === 401 && isRefreshable) {
return this.handle403or401RefreshError(request, next);
} else {
return throwError(error);
}
}));
Becoming something similar to the above (I renamed the 403 function)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.