Refactor API routes and component logic: Remove unused event and user management routes, streamline feedback handling in components, and enhance state management with transitions for improved user experience. Update service layer methods for better organization and maintainability across the application.
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 2m38s

This commit is contained in:
Julien Froidefond
2025-12-12 16:28:07 +01:00
parent 494ac3f503
commit db01c25de7
26 changed files with 747 additions and 743 deletions

View File

@@ -0,0 +1,46 @@
'use server'
import { revalidatePath } from 'next/cache'
import { auth } from '@/lib/auth'
import { userService } from '@/services/users/user.service'
import {
ValidationError,
NotFoundError,
} from '@/services/errors'
export async function updatePassword(data: {
currentPassword: string
newPassword: string
confirmPassword: string
}) {
try {
const session = await auth()
if (!session?.user) {
return { success: false, error: 'Non authentifié' }
}
await userService.validateAndUpdatePassword(
session.user.id,
data.currentPassword,
data.newPassword,
data.confirmPassword
)
revalidatePath('/profile')
return { success: true, message: 'Mot de passe modifié avec succès' }
} catch (error) {
console.error('Error updating password:', error)
if (error instanceof ValidationError) {
return { success: false, error: error.message }
}
if (error instanceof NotFoundError) {
return { success: false, error: error.message }
}
return { success: false, error: 'Erreur lors de la modification du mot de passe' }
}
}