From 83d919f06e33d1a2730aa32e4270ad6d79f67c56 Mon Sep 17 00:00:00 2001 From: Abdullah Atta Date: Wed, 13 Sep 2023 12:42:54 +0500 Subject: [PATCH] web: fix login form shown for split second before login --- apps/web/src/views/auth.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/web/src/views/auth.tsx b/apps/web/src/views/auth.tsx index 0af75aeb2..e737617ac 100644 --- a/apps/web/src/views/auth.tsx +++ b/apps/web/src/views/auth.tsx @@ -272,6 +272,7 @@ function LoginPassword(props: BaseAuthComponentProps<"login:password">) { type="login:password" title="Your account password" subtitle={"Your password is always hashed before leaving this device."} + loadForever loading={{ title: "Logging you in", subtitle: "Please wait while you are authenticated." @@ -806,6 +807,7 @@ type AuthFormProps = { loading: { title: string; subtitle: string }; type: TType; onSubmit: (form: AuthFormData[TType]) => Promise; + loadForever?: boolean; canSkip?: boolean; children?: | React.ReactNode @@ -813,7 +815,7 @@ type AuthFormProps = { }; export function AuthForm(props: AuthFormProps) { - const { title, subtitle, children, canSkip } = props; + const { title, subtitle, children, canSkip, loadForever } = props; const [isSubmitting, setIsSubmitting] = useState(false); const [error, setError] = useState(); const formRef = useRef(null); @@ -838,7 +840,9 @@ export function AuthForm(props: AuthFormProps) { try { setForm(form); await props.onSubmit(form); + if (!loadForever) setIsSubmitting(false); } catch (e) { + setIsSubmitting(false); const error = e as Error; if (error.message === "invalid_grant") { setError( @@ -847,8 +851,6 @@ export function AuthForm(props: AuthFormProps) { return; } setError(error.message); - } finally { - setIsSubmitting(false); } }} sx={{