mirror of https://github.com/buster-so/buster.git
check if user has an org first
This commit is contained in:
parent
db43289d71
commit
de85b20627
|
@ -1,9 +1,16 @@
|
|||
import { BusterOrganizationRole, BusterUserResponse } from '@/api/buster_rest';
|
||||
|
||||
export const checkIfUserIsAdmin = (userInfo?: BusterUserResponse | null) => {
|
||||
export const checkIfUserIsAdmin = (userInfo?: BusterUserResponse | null): boolean => {
|
||||
if (!userInfo) return false;
|
||||
|
||||
const userOrganization = userInfo?.organizations?.[0];
|
||||
|
||||
if (!userOrganization) return false;
|
||||
|
||||
const userRole = userOrganization.role;
|
||||
|
||||
return (
|
||||
!!userInfo &&
|
||||
(userInfo.organizations[0].role === BusterOrganizationRole.DATA_ADMIN ||
|
||||
userInfo.organizations[0].role === BusterOrganizationRole.WORKSPACE_ADMIN)
|
||||
userRole === BusterOrganizationRole.DATA_ADMIN ||
|
||||
userRole === BusterOrganizationRole.WORKSPACE_ADMIN
|
||||
);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue