feat: Remote Auth
This commit is contained in:
committed by
Aditya Chandel
parent
cb552b5ee2
commit
4c01561f1b
@@ -31,6 +31,11 @@ export class LoginComponent {
|
||||
errorMessage = '';
|
||||
|
||||
constructor(private authService: AuthService, private router: Router) {
|
||||
this.authService.remoteLogin().subscribe({
|
||||
next: () => {
|
||||
this.router.navigate(['/dashboard']);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
login(): void {
|
||||
|
||||
@@ -26,6 +26,17 @@ export class AuthService {
|
||||
);
|
||||
}
|
||||
|
||||
remoteLogin(): Observable<any> {
|
||||
return this.http.get<{ accessToken: string; refreshToken: string }>(`${this.apiUrl}/remote`).pipe(
|
||||
tap((response) => {
|
||||
if (response.accessToken && response.refreshToken) {
|
||||
this.saveTokens(response.accessToken, response.refreshToken);
|
||||
this.getRxStompService().activate();
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
refreshToken(): Observable<{ accessToken: string; refreshToken: string }> {
|
||||
const refreshToken = this.getRefreshToken();
|
||||
return this.http.post<{ accessToken: string; refreshToken: string }>(`${this.apiUrl}/refresh`, {refreshToken}).pipe(
|
||||
|
||||
Reference in New Issue
Block a user