Refactor public legal URLs and fix broken links

This commit is contained in:
dyzulk
2025-12-30 18:02:36 +07:00
parent 59160de9ab
commit ca3641e338
9 changed files with 146 additions and 109 deletions

View File

@@ -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 || ''),
};
};