mirror of
https://example.com
synced 2024-11-22 10:56:37 +09:00
fix(frontend): show 2fa code field in login only if 2fa is enabled
This commit is contained in:
parent
437d02ef5d
commit
0a270ca31a
1 changed files with 18 additions and 20 deletions
|
@ -79,10 +79,10 @@
|
||||||
{{ i18n.ts.retry }}
|
{{ i18n.ts.retry }}
|
||||||
</MkButton>
|
</MkButton>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="user && user.securityKeys" class="or-hr">
|
<div v-if="user && user.securityKeys && user.twoFactorEnabled" class="or-hr">
|
||||||
<p class="or-msg">{{ i18n.ts.or }}</p>
|
<p class="or-msg">{{ i18n.ts.or }}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="twofa-group totp-group">
|
<div v-if="user.twoFactorEnabled" class="twofa-group totp-group">
|
||||||
<p style="margin-bottom: 0">
|
<p style="margin-bottom: 0">
|
||||||
{{ i18n.ts.twoStepAuthentication }}
|
{{ i18n.ts.twoStepAuthentication }}
|
||||||
</p>
|
</p>
|
||||||
|
@ -247,25 +247,23 @@ function queryKey() {
|
||||||
function onSubmit() {
|
function onSubmit() {
|
||||||
signing.value = true;
|
signing.value = true;
|
||||||
console.log("submit");
|
console.log("submit");
|
||||||
if (!totpLogin.value && user.value && user.value.twoFactorEnabled) {
|
if (window.PublicKeyCredential && user.value.securityKeys) {
|
||||||
if (window.PublicKeyCredential && user.value.securityKeys) {
|
os.api("signin", {
|
||||||
os.api("signin", {
|
username: username.value,
|
||||||
username: username.value,
|
password: password.value,
|
||||||
password: password.value,
|
"hcaptcha-response": hCaptchaResponse.value,
|
||||||
"hcaptcha-response": hCaptchaResponse.value,
|
"g-recaptcha-response": reCaptchaResponse.value,
|
||||||
"g-recaptcha-response": reCaptchaResponse.value,
|
})
|
||||||
|
.then((res) => {
|
||||||
|
totpLogin.value = true;
|
||||||
|
signing.value = false;
|
||||||
|
challengeData.value = res;
|
||||||
|
return queryKey();
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.catch(loginFailed);
|
||||||
totpLogin.value = true;
|
} else if (!totpLogin.value && user.value && user.value.twoFactorEnabled) {
|
||||||
signing.value = false;
|
totpLogin.value = true;
|
||||||
challengeData.value = res;
|
signing.value = false;
|
||||||
return queryKey();
|
|
||||||
})
|
|
||||||
.catch(loginFailed);
|
|
||||||
} else {
|
|
||||||
totpLogin.value = true;
|
|
||||||
signing.value = false;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
os.api("signin", {
|
os.api("signin", {
|
||||||
username: username.value,
|
username: username.value,
|
||||||
|
|
Loading…
Reference in a new issue