Добавлена провера разрешений из старого варианта хранилища

This commit is contained in:
Александр Сироткин 2022-10-24 06:42:08 +05:00
parent 1b9db1c35a
commit 1337656828

View File

@ -45,7 +45,12 @@ export const setJSON = <T,>(name: StorageNames, data: T | null): boolean => {
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 getUserLogin = () => localStorage.getItem(StorageNames.login)
export const getUserToken = () => localStorage.getItem(StorageNames.token)