feat: Remote Auth

This commit is contained in:
Oleh Astappiev
2025-04-23 17:23:48 -06:00
committed by Aditya Chandel
parent cb552b5ee2
commit 4c01561f1b
10 changed files with 150 additions and 27 deletions
@@ -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(