feat: migrate authentication to Better Auth and update profile management logic

This commit is contained in:
Jose Selesan
2026-04-16 21:10:38 -03:00
parent 6dc8cae3a8
commit f98a0c2c02
3 changed files with 40 additions and 17 deletions

View File

@@ -20,6 +20,7 @@ type UpdateProfileParams = {
};
type UpdatePasswordParams = {
currentPassword?: string;
password: string;
};
@@ -172,11 +173,11 @@ export function AuthProvider({ children }: PropsWithChildren) {
}
return {
requiresEmailConfirmation: !signUpData?.session,
requiresEmailConfirmation: !signUpData || !('session' in signUpData),
};
},
updateProfile: async ({ fullName }) => {
const { error } = await authClient.user.update({
const { error } = await authClient.updateUser({
name: fullName,
});
@@ -184,10 +185,11 @@ export function AuthProvider({ children }: PropsWithChildren) {
throw error;
}
},
updatePassword: async ({ password }) => {
updatePassword: async ({ currentPassword, password }) => {
// Better Auth uses changePassword for authenticated users
const { error } = await authClient.changePassword({
newPassword: password,
currentPassword: currentPassword || '',
revokeOtherSessions: true,
});