Skip to content

Commit

Permalink
fix (client): user deletion to be safe
Browse files Browse the repository at this point in the history
  • Loading branch information
atsu1125 committed Mar 31, 2024
1 parent 7d2b2fe commit d5b53ec
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
1 change: 1 addition & 0 deletions locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,7 @@ createdAt: "Created at"
invitationRequiredToRegister: "This server is currently invitation only. Only those with an invitation code can register."
themeColor: "Theme Color"
preferTickerSoftwareColor: "Prefer Software Color on instance ticker"
typeToConfirm: "Please enter {x} to confirm"

_template:
edit: "Edit Template..."
Expand Down
1 change: 1 addition & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,7 @@ leaveGroupConfirm: "「{name}」から抜けますか?"
notSpecifiedMentionWarning: "宛先に含まれていないメンションがあります"
themeColor: "テーマカラー"
preferTickerSoftwareColor: "インスタンスティッカーにソフトウェアカラーを採用して表示する"
typeToConfirm: "この操作を行うには {x} と入力してください"

_template:
edit: "定型文を編集…"
Expand Down
29 changes: 22 additions & 7 deletions src/client/pages/instance/user-dialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import XModalWindow from '@/components/ui/modal-window.vue';
import Progress from '@/scripts/loading';
import { acct, userPage } from '../../filters/user';
import * as os from '@/os';
import { i18n } from '@/i18n';
export default defineComponent({
components: {
Expand Down Expand Up @@ -223,16 +224,30 @@ export default defineComponent({
text: this.$ts.deleteAccountConfirm,
});
if (confirm.canceled) return;
const process = async () => {
await os.api('admin/delete-account', { userId: this.user.id });
os.success();
};
await process().catch(e => {
const { canceled, result: username } = await os.dialog({
title: i18n.t('typeToConfirm', { x: this.user?.username }),
input: {
allowEmpty: false
}
});
if (canceled) return;
if (username === this.user?.username) {
const process = async () => {
await os.api('admin/delete-account', { userId: this.user.id });
os.success();
};
await process().catch(e => {
os.dialog({
type: 'error',
text: e.toString()
});
});
} else {
os.dialog({
type: 'error',
text: e.toString()
text: 'input not match',
});
});
}
await this.refreshUser();
},
Expand Down

0 comments on commit d5b53ec

Please sign in to comment.