diff options
| author | かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com> | 2024-03-22 15:03:21 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-22 15:03:21 +0900 |
| commit | c9c6424205f1d05813735a8f9c0e53a1ccc35e0e (patch) | |
| tree | 2c3663b539d62b53494e48ab4db5d0f32a5ae0fa /packages/frontend/src | |
| parent | fix(frontend): URLプレビューのto/hrefがない問題を修正 (diff) | |
| download | misskey-c9c6424205f1d05813735a8f9c0e53a1ccc35e0e.tar.gz misskey-c9c6424205f1d05813735a8f9c0e53a1ccc35e0e.tar.bz2 misskey-c9c6424205f1d05813735a8f9c0e53a1ccc35e0e.zip | |
enhance(frontend): TOTPの入力ダイアログを改良 (#13607)
* enhance(frontend): TOTPの入力ダイアログを改良
* Update Changelog
Diffstat (limited to 'packages/frontend/src')
| -rw-r--r-- | packages/frontend/src/components/MkInput.vue | 2 | ||||
| -rw-r--r-- | packages/frontend/src/components/MkPasswordDialog.vue | 26 | ||||
| -rw-r--r-- | packages/frontend/src/components/MkSignin.vue | 11 | ||||
| -rw-r--r-- | packages/frontend/src/pages/settings/2fa.qrdialog.vue | 2 | ||||
| -rw-r--r-- | packages/frontend/src/pages/settings/2fa.vue | 6 |
5 files changed, 29 insertions, 18 deletions
diff --git a/packages/frontend/src/components/MkInput.vue b/packages/frontend/src/components/MkInput.vue index d3cddad15b..88ef4635e6 100644 --- a/packages/frontend/src/components/MkInput.vue +++ b/packages/frontend/src/components/MkInput.vue @@ -22,6 +22,7 @@ SPDX-License-Identifier: AGPL-3.0-only :autocomplete="autocomplete" :autocapitalize="autocapitalize" :spellcheck="spellcheck" + :inputmode="inputmode" :step="step" :list="id" :min="min" @@ -63,6 +64,7 @@ const props = defineProps<{ mfmAutocomplete?: boolean | SuggestionType[], autocapitalize?: string; spellcheck?: boolean; + inputmode?: 'none' | 'text' | 'search' | 'email' | 'url' | 'numeric' | 'tel' | 'decimal'; step?: any; datalist?: string[]; min?: number; diff --git a/packages/frontend/src/components/MkPasswordDialog.vue b/packages/frontend/src/components/MkPasswordDialog.vue index c49526d8e2..e749725fea 100644 --- a/packages/frontend/src/components/MkPasswordDialog.vue +++ b/packages/frontend/src/components/MkPasswordDialog.vue @@ -19,18 +19,21 @@ SPDX-License-Identifier: AGPL-3.0-only <div style="margin-top: 16px;">{{ i18n.ts.authenticationRequiredToContinue }}</div> </div> - <div class="_gaps"> - <MkInput ref="passwordInput" v-model="password" :placeholder="i18n.ts.password" type="password" autocomplete="current-password webauthn" :withPasswordToggle="true"> - <template #prefix><i class="ti ti-password"></i></template> - </MkInput> + <form @submit.prevent="done"> + <div class="_gaps"> + <MkInput ref="passwordInput" v-model="password" :placeholder="i18n.ts.password" type="password" autocomplete="current-password webauthn" required :withPasswordToggle="true"> + <template #prefix><i class="ti ti-password"></i></template> + </MkInput> - <MkInput v-if="$i.twoFactorEnabled" v-model="token" type="text" pattern="^([0-9]{6}|[A-Z0-9]{32})$" autocomplete="one-time-code" :spellcheck="false"> - <template #label>{{ i18n.ts.token }} ({{ i18n.ts['2fa'] }})</template> - <template #prefix><i class="ti ti-123"></i></template> - </MkInput> + <MkInput v-if="$i.twoFactorEnabled" v-model="token" type="text" :pattern="isBackupCode ? '^[A-Z0-9]{32}$' :'^[0-9]{6}$'" autocomplete="one-time-code" required :spellcheck="false" :inputmode="isBackupCode ? undefined : 'numeric'"> + <template #label>{{ i18n.ts.token }} ({{ i18n.ts['2fa'] }})</template> + <template #prefix><i v-if="isBackupCode" class="ti ti-key"></i><i v-else class="ti ti-123"></i></template> + <template #caption><button class="_textButton" type="button" @click="isBackupCode = !isBackupCode">{{ isBackupCode ? i18n.ts.useTotp : i18n.ts.useBackupCode }}</button></template> + </MkInput> - <MkButton :disabled="(password ?? '') == '' || ($i.twoFactorEnabled && (token ?? '') == '')" primary rounded style="margin: 0 auto;" @click="done"><i class="ti ti-lock-open"></i> {{ i18n.ts.continue }}</MkButton> - </div> + <MkButton :disabled="(password ?? '') == '' || ($i.twoFactorEnabled && (token ?? '') == '')" type="submit" primary rounded style="margin: 0 auto;"><i class="ti ti-lock-open"></i> {{ i18n.ts.continue }}</MkButton> + </div> + </form> </MkSpacer> </MkModalWindow> </template> @@ -54,6 +57,7 @@ const emit = defineEmits<{ const dialog = shallowRef<InstanceType<typeof MkModalWindow>>(); const passwordInput = shallowRef<InstanceType<typeof MkInput>>(); const password = ref(''); +const isBackupCode = ref(false); const token = ref<string | null>(null); function onClose() { @@ -61,7 +65,7 @@ function onClose() { if (dialog.value) dialog.value.close(); } -function done(res) { +function done() { emit('done', { password: password.value, token: token.value }); if (dialog.value) dialog.value.close(); } diff --git a/packages/frontend/src/components/MkSignin.vue b/packages/frontend/src/components/MkSignin.vue index 852af01b5a..970aff825d 100644 --- a/packages/frontend/src/components/MkSignin.vue +++ b/packages/frontend/src/components/MkSignin.vue @@ -31,15 +31,15 @@ SPDX-License-Identifier: AGPL-3.0-only <div v-if="user && user.securityKeys" class="or-hr"> <p class="or-msg">{{ i18n.ts.or }}</p> </div> - <div class="twofa-group totp-group"> - <p style="margin-bottom:0;">{{ i18n.ts['2fa'] }}</p> + <div class="twofa-group totp-group _gaps"> <MkInput v-if="user && user.usePasswordLessLogin" v-model="password" type="password" autocomplete="current-password" :withPasswordToggle="true" required> <template #label>{{ i18n.ts.password }}</template> <template #prefix><i class="ti ti-lock"></i></template> </MkInput> - <MkInput v-model="token" type="text" pattern="^([0-9]{6}|[A-Z0-9]{32})$" autocomplete="one-time-code" :spellcheck="false" required> - <template #label>{{ i18n.ts.token }}</template> - <template #prefix><i class="ti ti-123"></i></template> + <MkInput v-model="token" type="text" :pattern="isBackupCode ? '^[A-Z0-9]{32}$' :'^[0-9]{6}$'" autocomplete="one-time-code" required :spellcheck="false" :inputmode="isBackupCode ? undefined : 'numeric'"> + <template #label>{{ i18n.ts.token }} ({{ i18n.ts['2fa'] }})</template> + <template #prefix><i v-if="isBackupCode" class="ti ti-key"></i><i v-else class="ti ti-123"></i></template> + <template #caption><button class="_textButton" type="button" @click="isBackupCode = !isBackupCode">{{ isBackupCode ? i18n.ts.useTotp : i18n.ts.useBackupCode }}</button></template> </MkInput> <MkButton type="submit" :disabled="signing" large primary rounded style="margin: 0 auto;">{{ signing ? i18n.ts.loggingIn : i18n.ts.login }}</MkButton> </div> @@ -70,6 +70,7 @@ const password = ref(''); const token = ref(''); const host = ref(toUnicode(configHost)); const totpLogin = ref(false); +const isBackupCode = ref(false); const queryingKey = ref(false); const credentialRequest = ref<CredentialRequestOptions | null>(null); diff --git a/packages/frontend/src/pages/settings/2fa.qrdialog.vue b/packages/frontend/src/pages/settings/2fa.qrdialog.vue index 2608560cc4..2ef664b9a3 100644 --- a/packages/frontend/src/pages/settings/2fa.qrdialog.vue +++ b/packages/frontend/src/pages/settings/2fa.qrdialog.vue @@ -52,7 +52,7 @@ SPDX-License-Identifier: AGPL-3.0-only <MkSpacer :marginMin="20" :marginMax="28"> <div class="_gaps"> <div>{{ i18n.ts._2fa.step3Title }}</div> - <MkInput v-model="token" autocomplete="one-time-code"></MkInput> + <MkInput v-model="token" autocomplete="one-time-code" inputmode="numeric"></MkInput> <div>{{ i18n.ts._2fa.step3 }}</div> </div> <div class="_buttonsCenter" style="margin-top: 16px;"> diff --git a/packages/frontend/src/pages/settings/2fa.vue b/packages/frontend/src/pages/settings/2fa.vue index d8c5f848fe..975f23cdd1 100644 --- a/packages/frontend/src/pages/settings/2fa.vue +++ b/packages/frontend/src/pages/settings/2fa.vue @@ -80,7 +80,7 @@ import MkSwitch from '@/components/MkSwitch.vue'; import FormSection from '@/components/form/section.vue'; import MkFolder from '@/components/MkFolder.vue'; import * as os from '@/os.js'; -import { signinRequired } from '@/account.js'; +import { signinRequired, updateAccount } from '@/account.js'; import { i18n } from '@/i18n.js'; const $i = signinRequired(); @@ -116,6 +116,10 @@ async function unregisterTOTP(): Promise<void> { os.apiWithDialog('i/2fa/unregister', { password: auth.result.password, token: auth.result.token, + }).then(res => { + updateAccount({ + twoFactorEnabled: false, + }); }).catch(error => { os.alert({ type: 'error', |