feat: migrate authentication to Better Auth and update profile management logic
This commit is contained in:
@@ -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,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user