FIX: Don't redirect when manually adding 2fa (#22474)

<img width="369" alt="Screenshot 2023-07-06 at 3 41 12 PM" src="https://github.com/discourse/discourse/assets/50783505/847d54ed-a62a-4266-b99e-31279f5bf747">

No changes in styling, the adding of classes was to give targets for testing
This commit is contained in:
Isaac Janzen 2023-07-06 16:44:40 -05:00 committed by GitHub
parent d41fa579c8
commit a9040be47c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 6 deletions

View File

@ -26,11 +26,15 @@
</div>
<p>
{{#if this.showSecondFactorKey}}
<div class="second-factor-key">
{{this.secondFactorKey}}
</div>
{{else}}
<a href {{on "click" this.enableShowSecondFactorKey}}>{{i18n
"user.second_factor.show_key_description"
}}</a>
<a
href
class="show-second-factor-key"
{{on "click" this.enableShowSecondFactorKey}}
>{{i18n "user.second_factor.show_key_description"}}</a>
{{/if}}
</p>
</div>

View File

@ -33,7 +33,9 @@ export default class SecondFactorAddTotp extends Component {
}
@action
enableShowSecondFactorKey() {
enableShowSecondFactorKey(e) {
e.preventDefault();
e.stopImmediatePropagation();
this.showSecondFactorKey = true;
}

View File

@ -66,8 +66,13 @@ acceptance("User Preferences - Second Factor", function (needs) {
await click(".new-totp");
assert.ok(exists(".qr-code img"), "shows qr code image");
await click(".add-totp");
await click(".modal a.show-second-factor-key");
assert.ok(
exists(".modal .second-factor-key"),
"displays second factor key"
);
await click(".add-totp");
assert.ok(
query(".alert-error").innerHTML.includes("provide a name and the code"),
"shows name/token missing error message"