Skip to content

Commit

Permalink
Fixes for #993
Browse files Browse the repository at this point in the history
  • Loading branch information
jgomer2001 committed Feb 4, 2019
1 parent f51fde6 commit d87cd47
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 51 deletions.
7 changes: 3 additions & 4 deletions Server/integrations/passport/PassportExternalAuthenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,10 @@ def prepareForStep(self, configurationAttributes, requestParameters, step):
identity = CdiUtil.bean(Identity)

if step == 1:
# This param is needed in passportlogin.xhtml
identity.setWorkingParameter("behaviour", "social")

#re-read the strategies config (for instance to know which strategies have enabled the email account linking)
self.parseProviderConfigs()
identity.setWorkingParameter("externalProviders", json.dumps(self.registeredProviders))

providerParam = self.customAuthzParameter
url = None

Expand Down Expand Up @@ -190,7 +189,7 @@ def prepareForStep(self, configurationAttributes, requestParameters, step):
def getExtraParametersForStep(self, configurationAttributes, step):
print "Passport. getExtraParametersForStep called"
if step == 1:
return Arrays.asList("selectedProvider")
return Arrays.asList("selectedProvider", "externalProviders")
elif step == 2:
return Arrays.asList("passport_user_profile")
return None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,10 @@ def prepareForStep(self, configurationAttributes, requestParameters, step):
identity = CdiUtil.bean(Identity)

if step == 1:
# This param is needed in passportlogin.xhtml
identity.setWorkingParameter("behaviour", "saml")

#re-read the strategies config (for instance to know which strategies have enabled the email account linking)
self.parseProviderConfigs()
identity.setWorkingParameter("externalProviders", json.dumps(self.registeredProviders))

providerParam = self.customAuthzParameter
url = None

Expand Down Expand Up @@ -200,7 +199,7 @@ def prepareForStep(self, configurationAttributes, requestParameters, step):
def getExtraParametersForStep(self, configurationAttributes, step):
print "Passport. getExtraParametersForStep called"
if step == 1:
return Arrays.asList("selectedProvider")
return Arrays.asList("selectedProvider", "externalProviders")
elif step == 2:
return Arrays.asList("passport_user_profile")
return None
Expand Down
52 changes: 9 additions & 43 deletions Server/src/main/webapp/auth/passport/passportlogin.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -319,18 +319,6 @@ input[type="text"]:focus, input[type="password"]:focus {
</div>

<script type="text/javascript">
var behaviour = "${identity.getWorkingParameter('behaviour')}";

try {
if (behaviour == "") {
behaviour = localStorage.behaviour ? localStorage.behaviour
: "";
} else {
localStorage.behaviour = behaviour;
}
} catch (e) {
}

function idp_redirect(provider) {
var form = document.forms.loginForm;
form["loginForm:provider"].value = provider;
Expand All @@ -354,37 +342,15 @@ input[type="text"]:focus, input[type="password"]:focus {

jQuery(document).ready(
function() {

var APIURL = window.location.origin;

if (behaviour == "social") {
//social provider
$.get(APIURL + "/passport/passportstrategies",
function(data) {

var providers = JSON.parse(data);
for ( var name in providers) {
dynamic_link(name,
providers[name].logo_img);
}

});
}
if (behaviour == "saml") {
//saml provider
$.get(APIURL + "/passport/saml_config", function(
data) {

var providers = JSON.parse(data);
for ( var name in providers) {
if (providers[name].enable == "true") {
dynamic_link(name,
providers[name].logo_img);
}
}

});
}
var jsonProviders = '${identity.getWorkingParameter('externalProviders')}'
try {
var providers = JSON.parse(jsonProviders)

for (var idprv in providers) {
dynamic_link(idprv, providers[idprv].logo_img)
}
} catch (e) {
}

//error message display
var errormsg = window.location.href.split("=");
Expand Down

0 comments on commit d87cd47

Please sign in to comment.