Fix password reset

This commit is contained in:
syuilo 2020-01-31 05:15:59 +09:00
parent c0847e8c4d
commit efc3631231
2 changed files with 7 additions and 14 deletions

View File

@ -336,6 +336,8 @@ registerSecurityKey: "セキュリティキーを登録する"
lastUsed: "最後の使用" lastUsed: "最後の使用"
unregister: "登録を解除" unregister: "登録を解除"
passwordLessLogin: "パスワード無しログイン" passwordLessLogin: "パスワード無しログイン"
resetPassword: "パスワードをリセット"
newPasswordIs: "新しいパスワードは「{password}」です"
_2fa: _2fa:
registerDevice: "デバイスを登録" registerDevice: "デバイスを登録"

View File

@ -2,7 +2,7 @@
<x-window @closed="() => { $emit('closed'); destroyDom(); }" :avatar="user"> <x-window @closed="() => { $emit('closed'); destroyDom(); }" :avatar="user">
<template #header><mk-user-name :user="user"/></template> <template #header><mk-user-name :user="user"/></template>
<div class="vrcsvlkm"> <div class="vrcsvlkm">
<mk-button @click="changePassword()">{{ $t('changePassword') }}</mk-button> <mk-button @click="resetPassword()" primary>{{ $t('resetPassword') }}</mk-button>
<mk-switch v-if="$store.state.i.isAdmin" @change="toggleModerator()" v-model="moderator">{{ $t('moderator') }}</mk-switch> <mk-switch v-if="$store.state.i.isAdmin" @change="toggleModerator()" v-model="moderator">{{ $t('moderator') }}</mk-switch>
<mk-switch @change="toggleSilence()" v-model="silenced">{{ $t('silence') }}</mk-switch> <mk-switch @change="toggleSilence()" v-model="silenced">{{ $t('silence') }}</mk-switch>
<mk-switch @change="toggleSuspend()" v-model="suspended">{{ $t('suspend') }}</mk-switch> <mk-switch @change="toggleSuspend()" v-model="suspended">{{ $t('suspend') }}</mk-switch>
@ -42,27 +42,18 @@ export default Vue.extend({
}, },
methods: { methods: {
async changePassword() { async resetPassword() {
const { canceled: canceled, result: newPassword } = await this.$root.dialog({
title: this.$t('newPassword'),
input: {
type: 'password'
}
});
if (canceled) return;
const dialog = this.$root.dialog({ const dialog = this.$root.dialog({
type: 'waiting', type: 'waiting',
iconOnly: true iconOnly: true
}); });
this.$root.api('admin/change-password', { this.$root.api('admin/reset-password', {
userId: this.user.id, userId: this.user.id,
newPassword }).then(({ password }) => {
}).then(() => {
this.$root.dialog({ this.$root.dialog({
type: 'success', type: 'success',
iconOnly: true, autoClose: true text: this.$t('newPasswordIs', { password })
}); });
}).catch(e => { }).catch(e => {
this.$root.dialog({ this.$root.dialog({