Skip to content

Commit

Permalink
Adicionando método para renovação do token
Browse files Browse the repository at this point in the history
  • Loading branch information
DiegoCarlito committed Dec 8, 2023
1 parent 1041d0f commit f01c238
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/app/pages/profile/profile.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,21 @@ export class ProfileComponent {
});
}

renewToken() {
this.authService.refreshToken().subscribe({
next: (response) => {
if (response && response.access_token) {
localStorage.setItem('token', response.access_token);
this.getUser();
}
},
error: (error: ErrorResponseType) => {
console.error('Failed to refresh token:', error);
this.authService.logout();
}
});
}

navigatorEdit(): void {
this.router.navigate([`/editUser/${this.user.id}`]);
}
Expand Down

0 comments on commit f01c238

Please sign in to comment.