logged in required

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

No files matched your search

+15
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;