From 1337656828bac7b26271ff5c80180737c8820d5f Mon Sep 17 00:00:00 2001 From: goodmice Date: Mon, 24 Oct 2022 06:42:08 +0500 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=B0=20?= =?UTF-8?q?=D1=80=D0=B0=D0=B7=D1=80=D0=B5=D1=88=D0=B5=D0=BD=D0=B8=D0=B9=20?= =?UTF-8?q?=D0=B8=D0=B7=20=D1=81=D1=82=D0=B0=D1=80=D0=BE=D0=B3=D0=BE=20?= =?UTF-8?q?=D0=B2=D0=B0=D1=80=D0=B8=D0=B0=D0=BD=D1=82=D0=B0=20=D1=85=D1=80?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D0=BB=D0=B8=D1=89=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/functions/storage.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/utils/functions/storage.ts b/src/utils/functions/storage.ts index a95182a..a75a33f 100644 --- a/src/utils/functions/storage.ts +++ b/src/utils/functions/storage.ts @@ -45,7 +45,12 @@ export const setJSON = (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)