add: reset password functionality
This commit is contained in:
+23
-2
@@ -14,6 +14,7 @@ import { useSignup } from '@/hooks/auth/useSignup';
|
||||
import { useCheckUserExistsLazy } from '@/hooks/auth/useCheckUserExists';
|
||||
import { useOtpRequest } from '@/hooks/auth/useOtpRequest';
|
||||
import { useOtpValidation } from '@/hooks/auth/useOtpValidation';
|
||||
import { useResetPassword } from '@/hooks/auth/useResetPassword';
|
||||
|
||||
type Props = object
|
||||
|
||||
@@ -34,8 +35,18 @@ function AuthIndex({ }: Props) {
|
||||
const { run: runUserExistCheck } = useCheckUserExistsLazy()
|
||||
const { run: runOtpRequest } = useOtpRequest();
|
||||
const { run: runOtpValidation } = useOtpValidation();
|
||||
const { run: runResetPassword } = useResetPassword();
|
||||
|
||||
|
||||
const resetStates = () => {
|
||||
setNumber('');
|
||||
setPassword('');
|
||||
setPasswordRepeat('');
|
||||
setOtp('');
|
||||
setShowPassword(false);
|
||||
setShowPasswordRepeat(false);
|
||||
setRememberMe(false);
|
||||
stop();
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (isAuthenticated) {
|
||||
@@ -130,7 +141,17 @@ function AuthIndex({ }: Props) {
|
||||
}
|
||||
else if (step == AUTH_STEP.ENTER_RESET_PASSWORD) {
|
||||
console.log("Password changed")
|
||||
setStep(AUTH_STEP.ENTER_NUMBER)
|
||||
try {
|
||||
await runResetPassword({
|
||||
phone: number,
|
||||
newPassword: password,
|
||||
otp
|
||||
})
|
||||
resetStates();
|
||||
setStep(AUTH_STEP.ENTER_NUMBER)
|
||||
} catch (ex) {
|
||||
console.error('Password reset failed: ', ex)
|
||||
}
|
||||
}
|
||||
else if (step == AUTH_STEP.ENTER_NEW_PASSWORD) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user