mirror of
https://github.com/wekan/wekan.git
synced 2025-12-24 03:10:12 +01:00
wait for service config load to redirect to oidc provider
This commit is contained in:
parent
05a98fa88b
commit
ee254cb9c8
2 changed files with 45 additions and 57 deletions
|
|
@ -50,33 +50,16 @@ Template.userFormsLayout.onCreated(function() {
|
|||
}
|
||||
});
|
||||
|
||||
if(!Meteor.user()?.profile)
|
||||
{
|
||||
|
||||
if (!Meteor.user()?.profile) {
|
||||
Meteor.call('isOidcRedirectionEnabled', (_, result) => {
|
||||
serviceName = 'oidc';
|
||||
if (result)
|
||||
{
|
||||
methodName = "loginWithOidc";
|
||||
var loginWithService = Meteor[methodName];
|
||||
if (result) {
|
||||
AccountsTemplates.options.socialLoginStyle = 'redirect';
|
||||
options = {
|
||||
loginStyle: AccountsTemplates.options.socialLoginStyle,
|
||||
};
|
||||
loginWithService(options, function(err) {
|
||||
AccountsTemplates.setDisabled(false);
|
||||
if (err && err instanceof Accounts.LoginCancelledError)
|
||||
{
|
||||
}
|
||||
else if (err && err instanceof ServiceConfiguration.ConfigError)
|
||||
{
|
||||
if (Accounts._loginButtonsSession) return Accounts._loginButtonsSession.configureService('oidc');
|
||||
}
|
||||
else
|
||||
{
|
||||
AccountsTemplates.submitCallback(err, state);
|
||||
}
|
||||
});
|
||||
console.log('options :',JSON.stringify(options,null,2));
|
||||
Meteor.loginWithOidc(options);
|
||||
}
|
||||
else console.log("oidc redirect not set");
|
||||
});
|
||||
|
|
@ -298,7 +281,6 @@ function getUserAuthenticationMethod(defaultAuthenticationMethod, match) {
|
|||
Meteor.subscribe('user-authenticationMethod', match, {
|
||||
onReady() {
|
||||
const user = Users.findOne();
|
||||
|
||||
const authenticationMethod = user
|
||||
? user.authenticationMethod
|
||||
: defaultAuthenticationMethod;
|
||||
|
|
|
|||
|
|
@ -229,6 +229,12 @@ if (Meteor.isServer) {
|
|||
]);
|
||||
}
|
||||
|
||||
function loadOidcConfig(){
|
||||
config = ServiceConfiguration.configurations.findOne({service: 'oidc'});
|
||||
configKeys = Object.keys(config);
|
||||
return Object.keys(config).length > 0;
|
||||
}
|
||||
|
||||
function sendInvitationEmail(_id) {
|
||||
const icode = InvitationCodes.findOne(_id);
|
||||
const author = Users.findOne(Meteor.userId());
|
||||
|
|
@ -509,8 +515,8 @@ if (Meteor.isServer) {
|
|||
return process.env.PASSWORD_LOGIN_ENABLED === 'false';
|
||||
},
|
||||
isOidcRedirectionEnabled(){
|
||||
return process.env.OIDC_REDIRECTION_ENABLED === 'true';
|
||||
},
|
||||
return process.env.OIDC_REDIRECTION_ENABLED === 'true' && loadOidcConfig();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue