mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 19:32:43 +08:00
UX: Display warning message about social logins disabled when 2FA is enabled.
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
import { default as computed } from 'ember-addons/ember-computed-decorators';
|
import { default as computed } from 'ember-addons/ember-computed-decorators';
|
||||||
import { default as DiscourseURL, userPath } from 'discourse/lib/url';
|
import { default as DiscourseURL, userPath } from 'discourse/lib/url';
|
||||||
import { popupAjaxError } from 'discourse/lib/ajax-error';
|
import { popupAjaxError } from 'discourse/lib/ajax-error';
|
||||||
|
import { LOGIN_METHODS } from 'discourse/models/login-method';
|
||||||
|
|
||||||
export default Ember.Controller.extend({
|
export default Ember.Controller.extend({
|
||||||
loading: false,
|
loading: false,
|
||||||
@ -20,6 +21,13 @@ export default Ember.Controller.extend({
|
|||||||
return loading ? 'loading' : 'submit';
|
return loading ? 'loading' : 'submit';
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@computed
|
||||||
|
displayOAuthWarning() {
|
||||||
|
return LOGIN_METHODS.some(name => {
|
||||||
|
return this.siteSettings[`enable_${name}_logins`];
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
toggleSecondFactor(enable) {
|
toggleSecondFactor(enable) {
|
||||||
if (!this.get('secondFactorToken')) return;
|
if (!this.get('secondFactorToken')) return;
|
||||||
this.set('loading', true);
|
this.set('loading', true);
|
||||||
|
@ -22,19 +22,21 @@ const LoginMethod = Ember.Object.extend({
|
|||||||
let methods;
|
let methods;
|
||||||
let preRegister;
|
let preRegister;
|
||||||
|
|
||||||
export function findAll(siteSettings, capabilities, isMobileDevice) {
|
export const LOGIN_METHODS = [
|
||||||
if (methods) { return methods; }
|
|
||||||
|
|
||||||
methods = [];
|
|
||||||
|
|
||||||
[
|
|
||||||
"google_oauth2",
|
"google_oauth2",
|
||||||
"facebook",
|
"facebook",
|
||||||
"twitter",
|
"twitter",
|
||||||
"yahoo",
|
"yahoo",
|
||||||
"instagram",
|
"instagram",
|
||||||
"github"
|
"github"
|
||||||
].forEach(name => {
|
];
|
||||||
|
|
||||||
|
export function findAll(siteSettings, capabilities, isMobileDevice) {
|
||||||
|
if (methods) { return methods; }
|
||||||
|
|
||||||
|
methods = [];
|
||||||
|
|
||||||
|
LOGIN_METHODS.forEach(name => {
|
||||||
if (siteSettings["enable_" + name + "_logins"]) {
|
if (siteSettings["enable_" + name + "_logins"]) {
|
||||||
const params = { name };
|
const params = { name };
|
||||||
if (name === "google_oauth2") {
|
if (name === "google_oauth2") {
|
||||||
|
@ -40,6 +40,10 @@
|
|||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
{{{i18n 'user.second_factor.enable_description'}}}
|
{{{i18n 'user.second_factor.enable_description'}}}
|
||||||
|
|
||||||
|
{{#if displayOAuthWarning}}
|
||||||
|
{{i18n 'user.second_factor.oauth_enabled_warning'}}
|
||||||
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -728,6 +728,7 @@ en:
|
|||||||
requiring a one-time token in addition to your password. These tokens
|
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>
|
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>.
|
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:
|
change_about:
|
||||||
title: "Change About Me"
|
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
|
||||||
|
);
|
||||||
|
});
|
Reference in New Issue
Block a user