Skip to content

Commit

Permalink
Update Sign On Panel (#701)
Browse files Browse the repository at this point in the history
Force for the local login to be collapsed when using SSO with an option to not if provided.

Fix sign in form saving user and pass by browser when using local login.

Since I was already near some of the stuff in index.php I added a few new lines to make the javascript that is output a little cleaner.
  • Loading branch information
plessbd authored Nov 19, 2018
1 parent 8bee626 commit 7abb72b
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 30 deletions.
4 changes: 4 additions & 0 deletions configuration/portal_settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ singlejobviewer = "off"
; set to 'off' in Open XDMoD until support has been added.
multiple_service_providers = "off"

[sso]
; Set to "on" to enable the local user option in login modal.
show_local_login = "off"

[internal]
dw_desc_cache = "off"

Expand Down
89 changes: 61 additions & 28 deletions html/gui/js/CCR.js
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,9 @@ CCR.xdmod.ui.actionLogin = function (config, animateTarget) {

if (success) {
decodedResponse = CCR.checkDecodedJSONResponseSuccess(data);
if (Ext.isGecko) {
Ext.getCmp('local_login_submit').fireEvent('click');
}
}

if (decodedResponse) {
Expand All @@ -1004,42 +1007,63 @@ CCR.xdmod.ui.actionLogin = function (config, animateTarget) {
});
};

var localLoginItems = [txtLoginUsername, txtLoginPassword, {
xtype: 'tbtext',
id: 'login_response'
}, new Ext.Container({
anchor: 'form',
autoWidth: true,
autoHeight: true,
layout: {
type: 'hbox'
var localLoginItems = [
txtLoginUsername,
txtLoginPassword,
{
xtype: 'tbtext',
id: 'login_response'
},
items: [new Ext.Button({
width: 75,
height: 22,
text: 'Sign in',
id: 'btn_sign_in',
handler: signInWithLocalAccount
}), new Ext.Container({
autoEl: 'div',
{
xtype: 'field',
id: 'local_login_submit',
autoCreate: {
tag: 'input',
type: 'submit'
},
hidden: true
},
{
xtype: 'container',
anchor: 'form',
autoWidth: true,
autoHeight: true,
id: 'assistancePrompt',
height: 38,
layout: {
type: 'hbox'
},
items: [{
xtype: 'tbtext',
html: '<a href="javascript:CCR.xdmod.ui.forgot_password()">Forgot your password?</a>',
id: 'forgot_password_link'
}, {
xtype: 'tbtext',
html: '<a href="javascript:presentSignUpViaLoginPrompt()">Don\'t have an account?</a>',
id: 'sign_up_link'
xtype: 'button',
width: 75,
height: 22,
text: 'Sign in',
id: 'btn_sign_in',
handler: signInWithLocalAccount
},
{
xtype: 'container',
autoEl: 'div',
autoWidth: true,
flex: 2,
height: 38,
id: 'assistancePrompt',
items: [{
xtype: 'tbtext',
html: '<a href="javascript:CCR.xdmod.ui.forgot_password()">Forgot your password?</a>',
id: 'forgot_password_link'
},
{
xtype: 'tbtext',
html: '<a href="javascript:presentSignUpViaLoginPrompt()">Don\'t have an account?</a>',
id: 'sign_up_link'
}]
}]
})]
})];
}
];

var SSOLoginFrm = CCR.xdmod.isSSOConfigured ? new Ext.form.FormPanel({
id: 'sso_login_form',
title: 'Sign in with ' + accountName + ':',
width: 321,
items: [{
xtype: 'button',
text: '<img src="' + CCR.xdmod.SSOLoginLink.icon + '" alt="Login here."></img>',
Expand Down Expand Up @@ -1090,6 +1114,15 @@ CCR.xdmod.ui.actionLogin = function (config, animateTarget) {

if (CCR.xdmod.isSSOConfigured) {
loginItems.push(SSOLoginFrm);
if (!CCR.xdmod.SSOShowLocalLogin) {
localLoginFrm.collapsible = true;
localLoginFrm.collapsed = true;
localLoginFrm.titleCollapse = true;
/**
* the span is added to the title because without it the cursor does not show as clickable.
*/
localLoginFrm.title = '<span style="cursor:pointer;">' + localLoginFrm.title + '</span>';
}
loginItems.push(localLoginFrm);
} else {
loginItems.push(localLoginFrm);
Expand Down
14 changes: 12 additions & 2 deletions html/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ function isReferrer($referrer)
}
} catch (exception $ex) {
}
print "CCR.xdmod.captcha_sitekey = '" . $captchaSiteKey . "';";
print "CCR.xdmod.captcha_sitekey = '" . $captchaSiteKey . "';\n";
if (!$userLoggedIn) {
$auth = null;
try {
Expand All @@ -317,10 +317,20 @@ function isReferrer($referrer)
// This will catch when a configuration directory does not exist if it is set in the environment level
}
if ($auth && $auth->isSamlConfigured()) {
$ssoShowLocalLogin = false;
try {
$ssoShowLocalLogin = filter_var(
xd_utilities\getConfiguration('sso', 'show_local_login'),
FILTER_VALIDATE_BOOLEAN
);
} catch (exception $ex) {
}

print "CCR.xdmod.isSSOConfigured = true;\n";
print "CCR.xdmod.SSOLoginLink = " . json_encode($auth->getLoginLink()) . ";\n";
print "CCR.xdmod.SSOShowLocalLogin = " . json_encode($ssoShowLocalLogin) . "\n";
} else {
print "CCR.xdmod.isSSOConfigured = false;";
print "CCR.xdmod.isSSOConfigured = false;\n";
}
}
if ($userLoggedIn) {
Expand Down
4 changes: 4 additions & 0 deletions templates/portal_settings.template
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ singlejobviewer = "off"
; set to 'off' in Open XDMoD until support has been added.
multiple_service_providers = "off"

[sso]
; Set to "on" to enable the local user option in login modal.
show_local_login = "off"

[internal]
dw_desc_cache = "off"

Expand Down

0 comments on commit 7abb72b

Please sign in to comment.