Fixes password prompt race condition (#4644)
This commit is contained in:
1 parent
61b010a60a
commit
52959fe257
1 file changed
+21
-10
@@ -1,6 +1,6 @@
|
||||
import crypto from "crypto";
|
||||
import { signOut } from "next-auth/react";
|
||||
import { useRef, useState, BaseSyntheticEvent } from "react";
|
||||
import { useRef, useState, BaseSyntheticEvent, useEffect } from "react";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
|
||||
import { ErrorCode } from "@calcom/lib/auth";
|
||||
@@ -124,15 +124,26 @@ const ProfileView = () => {
|
||||
deleteMeMutation.mutate({ password, totpCode });
|
||||
};
|
||||
|
||||
const formMethods = useForm({
|
||||
defaultValues: {
|
||||
avatar: user?.avatar || "",
|
||||
username: user?.username || "",
|
||||
name: user?.name || "",
|
||||
email: user?.email || "",
|
||||
bio: user?.bio || "",
|
||||
},
|
||||
});
|
||||
const formMethods = useForm<{
|
||||
avatar?: string;
|
||||
username?: string;
|
||||
name?: string;
|
||||
email?: string;
|
||||
bio?: string;
|
||||
}>();
|
||||
|
||||
const { reset } = formMethods;
|
||||
|
||||
useEffect(() => {
|
||||
if (user)
|
||||
reset({
|
||||
avatar: user?.avatar || "",
|
||||
username: user?.username || "",
|
||||
name: user?.name || "",
|
||||
email: user?.email || "",
|
||||
bio: user?.bio || "",
|
||||
});
|
||||
}, [reset, user]);
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
const passwordRef = useRef<HTMLInputElement>(null!);
|
||||
|
||||
Reference in new issue
Block a user