Update environment configuration and enhance user management features

- Changed VITE_SUPABASE_URL in .env.example for deployment consistency.
- Added new user management functionality to reset user passwords in UserManagement component.
- Updated supabase.ts to include first and last name fields in user profiles and added password reset functionality.
- Enhanced DashboardLayout to include a user profile view and improved user display in TopNavbar.
- Updated seed.sql to create additional users with roles for testing purposes.
This commit is contained in:
salirezav
2025-09-22 11:20:15 -04:00
parent d0aafb3d15
commit dbee99c316
23 changed files with 1398 additions and 31 deletions

View File

@@ -19,6 +19,8 @@ export type ResultsStatus = 'valid' | 'invalid'
export interface User {
id: string
email: string
first_name?: string
last_name?: string
roles: RoleName[]
status: UserStatus
created_at: string
@@ -257,6 +259,8 @@ export const userManagement = {
.select(`
id,
email,
first_name,
last_name,
status,
created_at,
updated_at
@@ -373,6 +377,8 @@ export const userManagement = {
.select(`
id,
email,
first_name,
last_name,
status,
created_at,
updated_at
@@ -397,6 +403,27 @@ export const userManagement = {
...profile,
roles: userRoles.map(ur => (ur.roles as any).name as RoleName)
}
},
// Reset user password to default (admin only)
async resetUserPassword(userId: string): Promise<{ user_id: string; email: string; new_password: string; reset_at: string }> {
const { data, error } = await supabase.rpc('reset_user_password', {
target_user_id: userId
})
if (error) throw error
return data
},
// Change user password (user can only change their own password)
async changeUserPassword(currentPassword: string, newPassword: string): Promise<{ user_id: string; email: string; password_changed_at: string }> {
const { data, error } = await supabase.rpc('change_user_password', {
current_password: currentPassword,
new_password: newPassword
})
if (error) throw error
return data
}
}