mirror of
https://github.com/dyzulk/trustlab.git
synced 2026-01-27 15:11:57 +07:00
Refactor public legal URLs and fix broken links
This commit is contained in:
@@ -104,6 +104,12 @@ export const useAuth = ({ middleware, redirectIfAuthenticated }: { middleware?:
|
||||
if (middleware === 'auth' && error) logout();
|
||||
}, [user, error, middleware, redirectIfAuthenticated, router]);
|
||||
|
||||
const hasRole = (role: string | string[]) => {
|
||||
if (!user) return false;
|
||||
if (Array.isArray(role)) return role.includes(user.role);
|
||||
return user.role === role;
|
||||
};
|
||||
|
||||
return {
|
||||
user,
|
||||
mutate,
|
||||
@@ -112,5 +118,10 @@ export const useAuth = ({ middleware, redirectIfAuthenticated }: { middleware?:
|
||||
logout,
|
||||
forgotPassword,
|
||||
resetPassword,
|
||||
hasRole,
|
||||
// Convenience getters
|
||||
isAdmin: user?.role === 'admin',
|
||||
isOwner: user?.role === 'owner',
|
||||
isAdminOrOwner: ['admin', 'owner'].includes(user?.role || ''),
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user