Fix refresh token mecanism.
This commit is contained in:
@@ -49,6 +49,7 @@ export class JwtInterceptor implements HttpInterceptor {
|
||||
this.userRestService.refreshToken(refreshTokenRequest)
|
||||
.then(refreshTokenResponse => {
|
||||
this.authenticationService.authenticate(refreshTokenResponse.accessToken, refreshTokenResponse.refreshToken);
|
||||
this.refreshTokenSubject.next(refreshTokenResponse.accessToken);
|
||||
})
|
||||
.catch(() => {
|
||||
return this.handleNoRefreshToken(initialError);
|
||||
|
||||
@@ -29,16 +29,7 @@ export class AuthenticationService {
|
||||
}
|
||||
|
||||
isAuthenticated(): boolean {
|
||||
let result = false;
|
||||
|
||||
const userDetails = this.extractUserDetails();
|
||||
|
||||
if (userDetails) {
|
||||
const authenticationExpiration = new Date(userDetails.exp * 1000);
|
||||
result = authenticationExpiration > new Date();
|
||||
}
|
||||
|
||||
return result;
|
||||
return !!localStorage.getItem(JWT_PARAM);
|
||||
}
|
||||
|
||||
getAuthenticatedUser(): User | undefined {
|
||||
|
||||
@@ -53,7 +53,18 @@ export class PictureSelectionDialog implements OnInit {
|
||||
this.dialogRef.close();
|
||||
}
|
||||
|
||||
uploadPicture(file: any): void {
|
||||
console.log("uploadFile", file);
|
||||
uploadPicture(fileSelectionEvent: any): void {
|
||||
const pictureFile = fileSelectionEvent.target.files[0];
|
||||
if (pictureFile) {
|
||||
this.pictureRestService.uploadPicture(pictureFile)
|
||||
.then(pictureId => {
|
||||
this.dialogRef.close(pictureId);
|
||||
})
|
||||
.catch(error => {
|
||||
const errorMessage = 'A technical error occured while uploading your picture.';
|
||||
console.error(errorMessage, error);
|
||||
this.snackBar.open(errorMessage, 'Close', { duration: 5000 });
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user