Private
Public Access
primer draft de la pagina
This commit is contained in:
1 parent
02a6c846dc
commit
fcc3952841
42 files changed
+1248
No files matched your search
@@ -0,0 +1,45 @@
|
||||
export interface AuthTokens {
|
||||
access_token: string;
|
||||
refresh_token: string;
|
||||
expires_in: number;
|
||||
token_type: string;
|
||||
}
|
||||
|
||||
export function setToken(token: string): void {
|
||||
if (typeof window !== 'undefined') {
|
||||
localStorage.setItem('token', token);
|
||||
}
|
||||
}
|
||||
|
||||
export function removeToken(): void {
|
||||
if (typeof window !== 'undefined') {
|
||||
localStorage.removeItem('token');
|
||||
}
|
||||
}
|
||||
|
||||
export function getToken(): string {
|
||||
if (typeof window !== 'undefined') {
|
||||
return localStorage.getItem('token') || '';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
export function setAuthTokens(auth: AuthTokens): void {
|
||||
if (typeof window !== 'undefined') {
|
||||
localStorage.setItem('auth', JSON.stringify(auth));
|
||||
}
|
||||
}
|
||||
|
||||
export function getAuthTokens(): AuthTokens | null {
|
||||
if (typeof window !== 'undefined') {
|
||||
const auth = localStorage.getItem('auth');
|
||||
return auth ? JSON.parse(auth) : null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export function removeAuthTokens(): void {
|
||||
if (typeof window !== 'undefined') {
|
||||
localStorage.removeItem('auth');
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user