FIX: Hide 'show associated accounts' button if moderators can't see emails

And minor prettier code alignments
This commit is contained in:
Vinoth Kannan 2019-02-26 13:49:27 +05:30
parent 2d247cc4e9
commit ed0120171c
2 changed files with 14 additions and 5 deletions

View File

@ -92,9 +92,9 @@ export default Ember.Controller.extend(
return userId !== this.get("currentUser.id");
},
@computed("model.second_factor_enabled")
canUpdateAssociatedAccounts(secondFactorEnabled) {
if (secondFactorEnabled) {
@computed("model.second_factor_enabled", "CanCheckEmails")
canUpdateAssociatedAccounts(secondFactorEnabled, canCheckEmails) {
if (secondFactorEnabled || !canCheckEmails) {
return false;
}
@ -106,8 +106,13 @@ export default Ember.Controller.extend(
@computed("showAllAuthTokens", "model.user_auth_tokens")
authTokens(showAllAuthTokens, tokens) {
tokens.sort((a, b) =>
a.is_active ? -1 : b.is_active ? 1 : b.seen_at.localeCompare(a.seen_at)
tokens.sort(
(a, b) =>
a.is_active
? -1
: b.is_active
? 1
: b.seen_at.localeCompare(a.seen_at)
);
return showAllAuthTokens

View File

@ -17,5 +17,9 @@ QUnit.test("updating of associated accounts", function(assert) {
controller.set("model.second_factor_enabled", false);
assert.equal(controller.get("canUpdateAssociatedAccounts"), false);
controller.set("CanCheckEmails", true);
assert.equal(controller.get("canUpdateAssociatedAccounts"), true);
});