UX: Display warning message about social logins disabled when 2FA is enabled.
This commit is contained in:
parent
50eb582fb2
commit
d9b4b12694
|
@ -1,6 +1,7 @@
|
|||
import { default as computed } from 'ember-addons/ember-computed-decorators';
|
||||
import { default as DiscourseURL, userPath } from 'discourse/lib/url';
|
||||
import { popupAjaxError } from 'discourse/lib/ajax-error';
|
||||
import { LOGIN_METHODS } from 'discourse/models/login-method';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
loading: false,
|
||||
|
@ -20,6 +21,13 @@ export default Ember.Controller.extend({
|
|||
return loading ? 'loading' : 'submit';
|
||||
},
|
||||
|
||||
@computed
|
||||
displayOAuthWarning() {
|
||||
return LOGIN_METHODS.some(name => {
|
||||
return this.siteSettings[`enable_${name}_logins`];
|
||||
});
|
||||
},
|
||||
|
||||
toggleSecondFactor(enable) {
|
||||
if (!this.get('secondFactorToken')) return;
|
||||
this.set('loading', true);
|
||||
|
|
|
@ -22,19 +22,21 @@ const LoginMethod = Ember.Object.extend({
|
|||
let methods;
|
||||
let preRegister;
|
||||
|
||||
export const LOGIN_METHODS = [
|
||||
"google_oauth2",
|
||||
"facebook",
|
||||
"twitter",
|
||||
"yahoo",
|
||||
"instagram",
|
||||
"github"
|
||||
];
|
||||
|
||||
export function findAll(siteSettings, capabilities, isMobileDevice) {
|
||||
if (methods) { return methods; }
|
||||
|
||||
methods = [];
|
||||
|
||||
[
|
||||
"google_oauth2",
|
||||
"facebook",
|
||||
"twitter",
|
||||
"yahoo",
|
||||
"instagram",
|
||||
"github"
|
||||
].forEach(name => {
|
||||
LOGIN_METHODS.forEach(name => {
|
||||
if (siteSettings["enable_" + name + "_logins"]) {
|
||||
const params = { name };
|
||||
if (name === "google_oauth2") {
|
||||
|
|
|
@ -40,6 +40,10 @@
|
|||
<div class="control-group">
|
||||
<div class="controls">
|
||||
{{{i18n 'user.second_factor.enable_description'}}}
|
||||
|
||||
{{#if displayOAuthWarning}}
|
||||
{{i18n 'user.second_factor.oauth_enabled_warning'}}
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -728,6 +728,7 @@ en:
|
|||
requiring a one-time token in addition to your password. These tokens
|
||||
can be generated on Android and iOS by <a href="https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2" target='_blank'>Google Authenticator</a>
|
||||
and on Windows Phone by <a href="https://www.microsoft.com/en-us/store/p/authenticator/9wzdncrfj3rj" target='_blank'>Authenticator</a>.
|
||||
oauth_enabled_warning: "Note that logins via social methods will be disabled once Two Factor Authentication has been enabled on your account."
|
||||
|
||||
change_about:
|
||||
title: "Change About Me"
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
moduleFor("controller:preferences/second-factor");
|
||||
|
||||
QUnit.test("displayOAuthWarning when OAuth login methods are disabled", assert => {
|
||||
let controller = this.subject({
|
||||
siteSettings: {
|
||||
enable_google_oauth2_logins: false
|
||||
}
|
||||
});
|
||||
|
||||
assert.equal(
|
||||
controller.get('displayOAuthWarning'),
|
||||
false
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("displayOAuthWarning when OAuth login methods are enabled", assert => {
|
||||
let controller = this.subject({
|
||||
siteSettings: {
|
||||
enable_google_oauth2_logins: true
|
||||
}
|
||||
});
|
||||
|
||||
assert.equal(
|
||||
controller.get('displayOAuthWarning'),
|
||||
true
|
||||
);
|
||||
});
|
Loading…
Reference in New Issue