forked from ddrilling/asb_cloud_front
Добавлена провера разрешений из старого варианта хранилища
This commit is contained in:
parent
1b9db1c35a
commit
1337656828
@ -45,7 +45,12 @@ export const setJSON = <T,>(name: StorageNames, data: T | null): boolean => {
|
|||||||
|
|
||||||
export const getUser = (): UserTokenDto | null => getJSON(StorageNames.user)
|
export const getUser = (): UserTokenDto | null => getJSON(StorageNames.user)
|
||||||
|
|
||||||
export const getUserPermissions = (): Permission[] | null => getUser()?.permissions?.map((perm) => perm.name as string) || null
|
export const getUserPermissions = (): Permission[] | null => {
|
||||||
|
let permissions = getUser()?.permissions?.map((perm) => perm.name as string)
|
||||||
|
if (!permissions) // TODO: Удалить в следующем релизе, вставлено для совместимости
|
||||||
|
permissions = localStorage.getItem(StorageNames.permissions)?.split(',')
|
||||||
|
return permissions || null
|
||||||
|
}
|
||||||
export const getUserId = () => Number(localStorage.getItem(StorageNames.userId)) || null
|
export const getUserId = () => Number(localStorage.getItem(StorageNames.userId)) || null
|
||||||
export const getUserLogin = () => localStorage.getItem(StorageNames.login)
|
export const getUserLogin = () => localStorage.getItem(StorageNames.login)
|
||||||
export const getUserToken = () => localStorage.getItem(StorageNames.token)
|
export const getUserToken = () => localStorage.getItem(StorageNames.token)
|
||||||
|
Loading…
Reference in New Issue
Block a user