logged in required

This commit is contained in:
grimhilt
2023-08-05 21:30:29 +02:00
parent 9e9a4b3897
commit fc942db1a1
3 changed files with 29 additions and 6 deletions

View File

@@ -1,8 +1,23 @@
import { useAuth } from './auth-provider';
import Authentication from '../pages/auth';
export const Perm = {
CREATE_ROLE: 0,
CREATE_PLAYLIST: 1,
VIEW_PLAYLIST: 2,
OWN_PLAYLIST: 3,
EDIT_PLAYLIST: 4,
};
const GrantAccess = ({ roles, children }) => {
const { user } = useAuth();
return roles.includes(user) ? children : null;
};
export const LoginRequired = ({ children }) => {
const { user } = useAuth();
if (!user) return <Authentication redirect={children} />;
else return children;
};
export default GrantAccess;