mirror of
https://github.com/wekan/wekan.git
synced 2025-04-23 13:37:09 -04:00
Merge pull request #5049 from cloudron-io/displayAuthenticationMethod-only-refers-to-select
Move authentication UI handling in correct place
This commit is contained in:
commit
767bbc5195
2 changed files with 54 additions and 40 deletions
|
@ -26,36 +26,64 @@ Template.userFormsLayout.onCreated(function () {
|
|||
templateInstance.isLoading = new ReactiveVar(false);
|
||||
|
||||
if (!ReactiveCache.getCurrentUser()?.profile) {
|
||||
Meteor.call('isOidcRedirectionEnabled', (_, result) => {
|
||||
if (result) {
|
||||
AccountsTemplates.options.socialLoginStyle = 'redirect';
|
||||
options = {
|
||||
loginStyle: AccountsTemplates.options.socialLoginStyle,
|
||||
};
|
||||
Meteor.loginWithOidc(options);
|
||||
}
|
||||
});
|
||||
Meteor.call('isOidcRedirectionEnabled', (_, result) => {
|
||||
if (result) {
|
||||
AccountsTemplates.options.socialLoginStyle = 'redirect';
|
||||
options = {
|
||||
loginStyle: AccountsTemplates.options.socialLoginStyle,
|
||||
};
|
||||
Meteor.loginWithOidc(options);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Meteor.call('isDisableRegistration', (_, result) => {
|
||||
if (result) {
|
||||
$('.at-signup-link').hide();
|
||||
}
|
||||
});
|
||||
|
||||
Meteor.call('isDisableForgotPassword', (_, result) => {
|
||||
if (result) {
|
||||
$('.at-pwd-link').hide();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Template.userFormsLayout.onRendered(() => {
|
||||
AccountsTemplates.state.form.keys = new Proxy(
|
||||
AccountsTemplates.state.form.keys,
|
||||
validator,
|
||||
);
|
||||
EscapeActions.executeAll();
|
||||
Meteor.call('getAuthenticationsEnabled', (_, result) => {
|
||||
let enabledAuthenticationMethods = [ 'password' ]; // we show/hide this based on isPasswordLoginEnabled
|
||||
|
||||
if (result) {
|
||||
Object.keys(result).forEach((m) => {
|
||||
if (result[m]) enabledAuthenticationMethods.push(m);
|
||||
});
|
||||
}
|
||||
|
||||
Meteor.call('isPasswordLoginEnabled', (_, result) => {
|
||||
if (result) {
|
||||
$('.at-pwd-form').show();
|
||||
}
|
||||
|
||||
if (result && enabledAuthenticationMethods.length > 1) {
|
||||
$('.at-sep').show();
|
||||
}
|
||||
});
|
||||
|
||||
Meteor.call('isDisableRegistration', (_, result) => {
|
||||
if (result) {
|
||||
$('.at-signup-link').hide();
|
||||
}
|
||||
});
|
||||
|
||||
Meteor.call('isDisableForgotPassword', (_, result) => {
|
||||
if (result) {
|
||||
$('.at-pwd-link').hide();
|
||||
}
|
||||
});
|
||||
|
||||
if (enabledAuthenticationMethods.indexOf('oauth2') !== -1) {
|
||||
// TODO find better way to run this code once the oauth2 UI is injected in the DOM
|
||||
(function waitForElementAndShow() {
|
||||
if (!$('.at-oauth')[0]) return setTimeout(waitForElementAndShow, 100);
|
||||
$('.at-oauth').show();
|
||||
})();
|
||||
}
|
||||
|
||||
AccountsTemplates.state.form.keys = new Proxy(
|
||||
AccountsTemplates.state.form.keys,
|
||||
validator,
|
||||
);
|
||||
EscapeActions.executeAll();
|
||||
});
|
||||
});
|
||||
|
||||
Template.userFormsLayout.helpers({
|
||||
|
|
|
@ -23,20 +23,6 @@ Template.connectionMethod.onCreated(function() {
|
|||
} else {
|
||||
content.hide();
|
||||
}
|
||||
|
||||
if (this.authenticationMethods.get().some((method) => method.value === 'oauth2')) {
|
||||
$('.at-oauth').show();
|
||||
}
|
||||
|
||||
Meteor.call('isPasswordLoginEnabled', (_, result) => {
|
||||
if (result) {
|
||||
$('.at-pwd-form').show();
|
||||
}
|
||||
|
||||
if (result && this.authenticationMethods.get().length > 1) {
|
||||
$('.at-sep').show();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue