fix(frontend): ログイン画面でキャプチャが表示されない問題を修正 (#14694)

* fix(frontend): ログイン画面でキャプチャが表示されない問題を修正

* rename
This commit is contained in:
かっこかり 2024-10-04 18:45:03 +09:00 committed by GitHub
parent 3d637af65b
commit b36d13d90c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 5 deletions

View File

@ -124,7 +124,7 @@ function onPasskeyLogin(): void {
page.value = 'passkey'; page.value = 'passkey';
waiting.value = false; waiting.value = false;
}) })
.catch(onLoginFailed); .catch(onSigninApiError);
} }
} }
@ -137,11 +137,11 @@ function onPasskeyDone(credential: AuthenticationPublicKeyCredential): void {
context: passkeyContext.value, context: passkeyContext.value,
}).then((res) => { }).then((res) => {
if (res.signinResponse == null) { if (res.signinResponse == null) {
onLoginFailed(); onSigninApiError();
return; return;
} }
emit('login', res.signinResponse); emit('login', res.signinResponse);
}).catch(onLoginFailed); }).catch(onSigninApiError);
} else if (userInfo.value != null) { } else if (userInfo.value != null) {
tryLogin({ tryLogin({
username: userInfo.value.username, username: userInfo.value.username,
@ -231,7 +231,7 @@ async function tryLogin(req: Partial<Misskey.entities.SigninRequest>): Promise<M
await onLoginSucceeded(res); await onLoginSucceeded(res);
return res; return res;
}).catch((err) => { }).catch((err) => {
onLoginFailed(err); onSigninApiError(err);
return Promise.reject(err); return Promise.reject(err);
}); });
} }
@ -242,16 +242,18 @@ async function onLoginSucceeded(res: Misskey.entities.SigninResponse) {
} }
} }
function onLoginFailed(err?: any): void { function onSigninApiError(err?: any): void {
const id = err?.id ?? null; const id = err?.id ?? null;
if (typeof err === 'object' && 'next' in err) { if (typeof err === 'object' && 'next' in err) {
switch (err.next) { switch (err.next) {
case 'captcha': { case 'captcha': {
needCaptcha.value = true;
page.value = 'password'; page.value = 'password';
break; break;
} }
case 'password': { case 'password': {
needCaptcha.value = false;
page.value = 'password'; page.value = 'password';
break; break;
} }
@ -365,6 +367,7 @@ function onLoginFailed(err?: any): void {
onBeforeUnmount(() => { onBeforeUnmount(() => {
password.value = ''; password.value = '';
needCaptcha.value = false;
userInfo.value = null; userInfo.value = null;
}); });
</script> </script>