fix passwd change
This commit is contained in:
parent
c2417c31da
commit
9b6b5cdda9
@ -3,6 +3,7 @@
|
||||
import { useState, useEffect, useCallback } from 'react'
|
||||
import { useTranslations } from 'next-intl'
|
||||
import { useBetterAuth } from '@/hooks/useBetterAuth'
|
||||
import { changePassword } from '@/lib/auth-client'
|
||||
import { Header } from '@/components/layout/Header'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Input } from '@/components/ui/input'
|
||||
@ -193,9 +194,19 @@ export default function ProfilePage() {
|
||||
setSaveStatus({ type: null, message: '' })
|
||||
|
||||
try {
|
||||
// TODO: 实现Better Auth密码更新
|
||||
// Better Auth的密码更新需要通过特殊的API端点
|
||||
setSaveStatus({ type: 'error', message: 'Password update is not yet implemented for Better Auth' })
|
||||
// 使用Better Auth的changePassword方法
|
||||
const { data, error } = await changePassword({
|
||||
newPassword: formData.newPassword,
|
||||
currentPassword: formData.currentPassword,
|
||||
revokeOtherSessions: false, // 保持其他会话不被撤销
|
||||
})
|
||||
|
||||
if (error) {
|
||||
throw new Error(error.message || 'Failed to change password')
|
||||
}
|
||||
|
||||
setSaveStatus({ type: 'success', message: t('passwordUpdatedSuccessfully') })
|
||||
setFormData({ ...formData, currentPassword: '', newPassword: '', confirmPassword: '' })
|
||||
|
||||
} catch (error: unknown) {
|
||||
setSaveStatus({ type: 'error', message: (error instanceof Error ? error.message : 'Unknown error') || t('failedToUpdatePassword') })
|
||||
|
@ -11,5 +11,6 @@ export const {
|
||||
signUp,
|
||||
signOut,
|
||||
useSession,
|
||||
getSession
|
||||
getSession,
|
||||
changePassword
|
||||
} = authClient
|
Loading…
Reference in New Issue
Block a user