Updated token validation

This commit is contained in:
itzMiney committed 2025-03-15 21:32:19 +01:00
1 parent 94c87b933f
commit 3dbc562147
4 files changed
+118 -43

No files matched your search

+8 -1
View File
@@ -1,6 +1,6 @@
import {Injectable} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {Observable, tap} from 'rxjs';
import {Observable, of, tap} from 'rxjs';
@Injectable({
providedIn: 'root'
@@ -22,4 +22,11 @@ export class AuthService {
})
);
}
isTokenValid(token: string | null) {
if (!token) return of(false);
return this.http.get<boolean>('/api/users', {
headers: { Authorization: `Bearer ${token}` }
})
}
}