mirror of
https://github.com/discourse/discourse.git
synced 2025-09-05 08:59:27 +08:00
UX: Display warning message about social logins disabled when 2FA is enabled.
This commit is contained in:
parent
50eb582fb2
commit
d9b4b12694
5 changed files with 50 additions and 8 deletions
|
@ -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>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue