Improve frontend auth handling
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
const TOKEN_STORAGE_KEY = 'token';
|
||||
|
||||
export const getToken = (): string | null => {
|
||||
try {
|
||||
return localStorage.getItem(TOKEN_STORAGE_KEY);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
export const setToken = (token: string) => {
|
||||
try {
|
||||
localStorage.setItem(TOKEN_STORAGE_KEY, token);
|
||||
} catch {
|
||||
// ingore
|
||||
}
|
||||
};
|
||||
|
||||
export const removeToken = () => {
|
||||
try {
|
||||
localStorage.removeItem(TOKEN_STORAGE_KEY);
|
||||
} catch {
|
||||
// ingore
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user