Skip to content

Commit

Permalink
improve messaging when disabling 2fa for other user (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
imorland committed Feb 13, 2024
1 parent 2f25289 commit 2102bf0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
10 changes: 9 additions & 1 deletion js/src/forum/components/TwoFactorDisableConfirmModal .tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Button from 'flarum/common/components/Button';
import User from 'flarum/common/models/User';
import { ILoginModalAttrs } from 'flarum/forum/components/LogInModal';
import type Mithril from 'mithril';
import username from 'flarum/common/helpers/username';

export interface TwoFactorDisableConfirmModalAttrs extends ILoginModalAttrs {
user: User;
Expand All @@ -26,9 +27,16 @@ export default class TwoFactorDisableConfirmModal extends Modal<TwoFactorDisable
}

content() {
const isSelf = app.session.user?.id() === this.attrs.user.id();
const thisUser = this.attrs.user;
return (
<div className="Modal-body">
<p>{app.translator.trans('ianm-twofactor.forum.security.confirm_disable_2fa_text')}</p>
<p>
{app.translator.trans(
isSelf ? 'ianm-twofactor.forum.security.confirm_disable_2fa_text' : 'ianm-twofactor.forum.security.confirm_disable_2fa_text_other_user',
{ username: username(thisUser) }
)}
</p>
<div className="Form-group">
<Button className="Button Button--danger" onclick={this.disable.bind(this)} loading={this.loading}>
{app.translator.trans('ianm-twofactor.forum.security.disable_2fa_button')}
Expand Down
1 change: 1 addition & 0 deletions locale/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ ianm-twofactor:
ok_button: Ok
confirm_disable_2fa_title: Confirm Disabling Two-Factor Authentication
confirm_disable_2fa_text: Are you sure you want to disable Two-Factor Authentication?
confirm_disable_2fa_text_other_user: Are you sure you want to disable Two-Factor Authentication for {username}? This will remove all backup codes and disable 2FA for their account.
cannot_disable: The current configuration dictates that you cannot disable Two-Factor Authentication.
cannot_disable_tooltip: Cannot disable 2FA
cancel_button: Cancel
Expand Down

0 comments on commit 2102bf0

Please sign in to comment.