Updated token validation
This commit is contained in:
1 parent
94c87b933f
commit
3dbc562147
4 files changed
+118
-43
No files matched your search
@@ -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}` }
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user