diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2023-09-22 14:12:33 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-22 14:12:33 +0900 |
| commit | c836157edb869e80b15f51bb8f48725e3b898b9a (patch) | |
| tree | c275a865b697afa4c5d045d16b1ca8999999f9cf /packages/frontend/src/components | |
| parent | tweak ui (diff) | |
| download | misskey-c836157edb869e80b15f51bb8f48725e3b898b9a.tar.gz misskey-c836157edb869e80b15f51bb8f48725e3b898b9a.tar.bz2 misskey-c836157edb869e80b15f51bb8f48725e3b898b9a.zip | |
enhance: 二要素認証設定時のセキュリティを強化 (#11863)
* enhance: 二要素認証設定時のセキュリティを強化
パスワード入力が必要な操作を行う際、二要素認証が有効であれば確認コードの入力も必要にする
* Update CoreModule.ts
* Update 2fa.ts
* wip
* wip
* Update 2fa.ts
* tweak
Diffstat (limited to 'packages/frontend/src/components')
| -rw-r--r-- | packages/frontend/src/components/MkInput.vue | 4 | ||||
| -rw-r--r-- | packages/frontend/src/components/MkPasswordDialog.vue | 70 |
2 files changed, 74 insertions, 0 deletions
diff --git a/packages/frontend/src/components/MkInput.vue b/packages/frontend/src/components/MkInput.vue index e9397ce86f..315ce958c5 100644 --- a/packages/frontend/src/components/MkInput.vue +++ b/packages/frontend/src/components/MkInput.vue @@ -155,6 +155,10 @@ onMounted(() => { } }); }); + +defineExpose({ + focus, +}); </script> <style lang="scss" module> diff --git a/packages/frontend/src/components/MkPasswordDialog.vue b/packages/frontend/src/components/MkPasswordDialog.vue new file mode 100644 index 0000000000..afb4929fcf --- /dev/null +++ b/packages/frontend/src/components/MkPasswordDialog.vue @@ -0,0 +1,70 @@ +<!-- +SPDX-FileCopyrightText: syuilo and other misskey contributors +SPDX-License-Identifier: AGPL-3.0-only +--> + +<template> +<MkModalWindow + ref="dialog" + :width="370" + :height="400" + @close="onClose" + @closed="emit('closed')" +> + <template #header>{{ i18n.ts.authentication }}</template> + + <MkSpacer :marginMin="20" :marginMax="28"> + <div style="padding: 0 0 16px 0; text-align: center;"> + <i class="ti ti-lock" style="font-size: 32px; color: var(--accent);"></i> + <div style="margin-top: 10px;">{{ 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> + + <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> + + <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> + </MkSpacer> +</MkModalWindow> +</template> + +<script lang="ts" setup> +import { onMounted } from 'vue'; +import MkInput from '@/components/MkInput.vue'; +import MkButton from '@/components/MkButton.vue'; +import MkModalWindow from '@/components/MkModalWindow.vue'; +import { i18n } from '@/i18n.js'; +import { $i } from '@/account.js'; + +const emit = defineEmits<{ + (ev: 'done', v: { password: string; token: string | null; }): void; + (ev: 'closed'): void; + (ev: 'cancelled'): void; +}>(); + +const dialog = $shallowRef<InstanceType<typeof MkModalWindow>>(); +const passwordInput = $shallowRef<InstanceType<typeof MkInput>>(); +const password = $ref(''); +const token = $ref(null); + +function onClose() { + emit('cancelled'); + if (dialog) dialog.close(); +} + +function done(res) { + emit('done', { password, token }); + if (dialog) dialog.close(); +} + +onMounted(() => { + if (passwordInput) passwordInput.focus(); +}); +</script> |