From efc3631231f542c90a1f03015d67bf5c84383192 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 31 Jan 2020 05:15:59 +0900 Subject: [PATCH] Fix password reset --- locales/ja-JP.yml | 2 ++ .../components/user-moderate-dialog.vue | 19 +++++-------------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 512a72b3e..3b1ed879e 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -336,6 +336,8 @@ registerSecurityKey: "セキュリティキーを登録する" lastUsed: "最後の使用" unregister: "登録を解除" passwordLessLogin: "パスワード無しログイン" +resetPassword: "パスワードをリセット" +newPasswordIs: "新しいパスワードは「{password}」です" _2fa: registerDevice: "デバイスを登録" diff --git a/src/client/components/user-moderate-dialog.vue b/src/client/components/user-moderate-dialog.vue index 46915b2e9..f45342564 100644 --- a/src/client/components/user-moderate-dialog.vue +++ b/src/client/components/user-moderate-dialog.vue @@ -2,7 +2,7 @@
- {{ $t('changePassword') }} + {{ $t('resetPassword') }} {{ $t('moderator') }} {{ $t('silence') }} {{ $t('suspend') }} @@ -42,27 +42,18 @@ export default Vue.extend({ }, methods: { - async changePassword() { - const { canceled: canceled, result: newPassword } = await this.$root.dialog({ - title: this.$t('newPassword'), - input: { - type: 'password' - } - }); - if (canceled) return; - + async resetPassword() { const dialog = this.$root.dialog({ type: 'waiting', iconOnly: true }); - this.$root.api('admin/change-password', { + this.$root.api('admin/reset-password', { userId: this.user.id, - newPassword - }).then(() => { + }).then(({ password }) => { this.$root.dialog({ type: 'success', - iconOnly: true, autoClose: true + text: this.$t('newPasswordIs', { password }) }); }).catch(e => { this.$root.dialog({