Skip to content

Commit

Permalink
Show loading state on verify button
Browse files Browse the repository at this point in the history
  • Loading branch information
datlechin authored Dec 2, 2023
1 parent 8ac4518 commit ebdf133
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion js/src/forum/components/TwoFactorEnableModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default class TwoFactorEnableModal extends Modal {
this.token = Stream('');
this.code = null;
this.activeTab = 'qrcode';
this.loading = false;
}

className() {
Expand Down Expand Up @@ -108,7 +109,11 @@ export default class TwoFactorEnableModal extends Modal {
/>
</div>
<div className="Form-group">
<Button type="submit" className="Button Button--primary" onclick={this.verifyToken.bind(this)}>
<Button
type="submit"
className="Button Button--primary" onclick={this.verifyToken.bind(this)}
loading={this.loading}
>
{app.translator.trans('ianm-twofactor.forum.security.verify_button')}
</Button>
</div>
Expand Down Expand Up @@ -153,6 +158,8 @@ export default class TwoFactorEnableModal extends Modal {
}

verifyToken() {
this.loading = true;

app
.request({
method: 'POST',
Expand All @@ -165,6 +172,7 @@ export default class TwoFactorEnableModal extends Modal {
this.backupCodes = response.backupCodes;
this.status = 'displayBackupCodes';
this.user.twoFactorEnabled(true);
this.loading = false;
m.redraw();
})
.catch((error) => {
Expand Down

0 comments on commit ebdf133

Please sign in to comment.