fix: (regression) error displayed after successful login

Massimo Melina committed Sep 12, 2023 at 22:52 UTC 465b69e533ccfaff3ddfd090a9e66f4610470974
1 file changed +5 -1
frontend/src/login.ts
+5 -1
@@ -45,6 +45,7 @@ export async function loginDialog(navigate: ReturnType<typeof useNavigate>) {
45 return lastPromise = new Promise(resolve => {
46 if (closeLoginDialog)
47 return lastPromise
48 + let going = false
49 const { close } = newDialog({
50 className: 'login-dialog dialog-login',
51 icon: () => hIcon('login'),
@@ -104,7 +105,8 @@ export async function loginDialog(navigate: ReturnType<typeof useNavigate>) {
105 ev?.stopPropagation()
106 const usr = usrRef.current?.value
107 const pwd = pwdRef.current?.value
107 - if (!usr || !pwd) return
108 + if (going || !usr || !pwd) return
109 + going = true
110 try {
111 const res = await login(usr, pwd)
112 close()
@@ -113,6 +115,8 @@ export async function loginDialog(navigate: ReturnType<typeof useNavigate>) {
115 } catch (err: any) {
116 await alertDialog(err)
117 usrRef.current?.focus()
118 + } finally {
119 + going = false
120 }
121 }
122