useAuth
Authentication and user management composable.
Import
typescript
const {
profile,
isAdmin,
isAuthenticated,
signInWithEmail,
signUp,
signOut,
promoteToAdmin,
demoteToUser,
listUsers,
} = useAuth()Return Values
| Property | Type | Description |
|---|---|---|
profile | Ref<UserProfile | null> | Current user's profile |
isAdmin | ComputedRef<boolean> | Whether current user is admin |
isAuthenticated | ComputedRef<boolean> | Whether user is logged in |
Methods
| Method | Parameters | Returns | Description |
|---|---|---|---|
signInWithEmail | email: string, password: string | Promise<void> | Sign in with email/password |
signUp | email: string, password: string | Promise<void> | Register new account |
signOut | — | Promise<void> | Sign out current user |
promoteToAdmin | userId: string | Promise<void> | Promote user to admin (admin only) |
demoteToUser | userId: string | Promise<void> | Demote admin to user (admin only) |
listUsers | — | Promise<UserProfile[]> | List all users (admin only) |
deactivateUser | userId: string | Promise<void> | Soft-ban user (admin only) |
reactivateUser | userId: string | Promise<void> | Unban user (admin only) |
Supabase Functions Used
pip_ai_get_my_profile()— Get current user profilepip_ai_check_is_admin()— Check admin statuspip_ai_promote_to_admin()— Promote userpip_ai_list_users()— List users
Source
app/composables/useAuth.ts