Added roles support
This commit is contained in:
parent
2b00c8425d
commit
da9eedc94e
17 changed files with 390 additions and 250 deletions
|
|
@ -1,11 +1,12 @@
|
|||
import { useCallback } from 'react';
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
import { getAuthToken, getCurrentUser, signIn, signOut } from '../redux';
|
||||
import { getAuthToken, getCurrentUser, getIsAdmin, signIn, signOut } from '../redux';
|
||||
|
||||
export function useAuth() {
|
||||
const dispatch = useDispatch();
|
||||
const currentUser = useSelector(getCurrentUser);
|
||||
const authToken = useSelector(getAuthToken);
|
||||
const isAdmin = useSelector(getIsAdmin);
|
||||
|
||||
const logIn = useCallback(
|
||||
(params) => {
|
||||
|
|
@ -21,6 +22,7 @@ export function useAuth() {
|
|||
return {
|
||||
authToken,
|
||||
currentUser,
|
||||
isAdmin,
|
||||
logIn,
|
||||
logOut,
|
||||
};
|
||||
|
|
|
|||
Reference in a new issue