mirror of
https://github.com/vernu/textbee.git
synced 2026-02-20 07:34:00 -05:00
17 lines
557 B
TypeScript
17 lines
557 B
TypeScript
import { UserEntity } from '../services/types'
|
|
import { LOCAL_STORAGE_KEY } from './constants'
|
|
|
|
export const saveUserAndToken = (user: UserEntity, accessToken: string) => {
|
|
if (typeof localStorage !== 'undefined') {
|
|
localStorage.setItem(LOCAL_STORAGE_KEY.USER, JSON.stringify(user))
|
|
localStorage.setItem(LOCAL_STORAGE_KEY.TOKEN, accessToken)
|
|
}
|
|
}
|
|
|
|
export const removeUserAndToken = () => {
|
|
if (typeof localStorage !== 'undefined') {
|
|
localStorage.removeItem(LOCAL_STORAGE_KEY.USER)
|
|
localStorage.removeItem(LOCAL_STORAGE_KEY.TOKEN)
|
|
}
|
|
}
|