mirror of
https://github.com/Unleash/unleash.git
synced 2024-10-18 20:09:08 +02:00
213e8950d3
* refactor: allow existing tsc errors * refactor: add missing component key * refactor: port login auth to TS/SWR * refactor: replace incorrect CREATE_TAG_TYPE with UPDATE_TAG_TYPE * refactor: fix AccessProvider permission mocks * refactor: add types to AccessContext * refactor: fix file extension * refactor: remove default export * refactor: remove unused IAddedUser interface * refactor: comment on the permissions prop * refactor: split auth hooks * feat: auth tests * fix: setup separate e2e tests * fix: naming * fix: lint * fix: spec path * fix: missing store * feat: add more tests Co-authored-by: Fredrik Oseberg <fredrik.no@gmail.com>
25 lines
651 B
TypeScript
25 lines
651 B
TypeScript
import { IPermission } from '../../../../interfaces/user';
|
|
import { useAuthEndpoint } from './useAuthEndpoint';
|
|
|
|
interface IUseAuthPermissionsOutput {
|
|
permissions?: IPermission[];
|
|
refetchPermissions: () => void;
|
|
loading: boolean;
|
|
error?: Error;
|
|
}
|
|
|
|
export const useAuthPermissions = (): IUseAuthPermissionsOutput => {
|
|
const auth = useAuthEndpoint();
|
|
const permissions =
|
|
auth.data && 'permissions' in auth.data
|
|
? auth.data.permissions
|
|
: undefined;
|
|
|
|
return {
|
|
permissions,
|
|
refetchPermissions: auth.refetchAuth,
|
|
loading: auth.loading,
|
|
error: auth.error,
|
|
};
|
|
};
|