Skip to content

Commit

Permalink
Merge pull request #102 from midas-isg/front-end-updates
Browse files Browse the repository at this point in the history
Front end updates
  • Loading branch information
JohnLevander authored Aug 30, 2017
2 parents 62dd6d9 + 46174da commit 5d2563d
Showing 1 changed file with 62 additions and 46 deletions.
108 changes: 62 additions & 46 deletions app/security/auth0/views/login.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,68 @@

<!DOCTYPE html>
<html lang="en">
<head>
<title>Log In - SPEW Web</title>
</head>
<body>
<script src="https://cdn.auth0.com/w2/auth0-6.8.js"></script>
<script type="text/javascript">
(function() {
var auth0 = new Auth0({
domain: '@aid.domain',
clientID: '@aid.clientId',
callbackURL: '@callbackUrl'
});
<head>
<title>Log In - SPEW Web</title>
</head>
<body>
<script src="https://cdn.auth0.com/w2/auth0-6.8.js"></script>
<script type="text/javascript">
(function() {
var CONTEXT = '@http_context()',
auth0 = new Auth0({
domain: '@aid.domain',
clientID: '@aid.clientId',
callbackURL: '@callbackUrl'
}),
title = "Apollo LS",
message = "Please login to use the services",
hash = window.location.hash.substr(1),
link = location.origin + CONTEXT + '/about',
returnTitle = "About LS",
loggedInUserId;

auth0.getSSOData(function (err, data) {
var loggedInUserId = '@userId';
if (data && data.sso === true) {
console.log('SSO: an Auth0 SSO session already exists');
if (loggedInUserId !== data.lastUsedUserID) {
console.log("SSO Session but NOT locally authenticated ");
auth0.login({
// state: '$ {state}',
scope: 'openid name email picture'
}, function (err) {
console.error('Error logging in: ' + err);
});
} else {
console.log("SSO Session and locally authenticated ");
window.location = CONTEXT;
}
} else if (loggedInUserId){
console.log("NO SSO Session but locally authenticated -> log them out locally");
window.location = CONTEXT + '/logout';
} else {
console.log("NO SSO Session and NOT locally authenticated ");
var title = "Apollo LS";
var message = "Please login to use the services";
var hash = window.location.hash.substr(1);
if (hash.match('^logout')){
message = "Logged out successfully.";
}
window.location = '@aid.hubWsUrl/sso?returnToUrl='
+ encodeURIComponent(window.location) + '&title=' + title + '&message=' + message;
}
});
})();
</script>
</body>
auth0.getSSOData(function (err, data) {
loggedInUserId = '@userId';

if (data && data.sso === true) {
console.log('SSO: an Auth0 SSO session already exists');

if (loggedInUserId !== data.lastUsedUserID) {
console.log("SSO Session but NOT locally authenticated ");

auth0.login({
// state: '$ {state}',
scope: 'openid name email picture'
},
function (err) {
console.error('Error logging in: ' + err);
}
);
}
else {
console.log("SSO Session and locally authenticated ");
window.location = CONTEXT;
}
}
else if (loggedInUserId){
console.log("NO SSO Session but locally authenticated -> log them out locally");
window.location = CONTEXT + '/logout';
}
else {
console.log("NO SSO Session and NOT locally authenticated ");

if (hash.match('^logout')) {
message = "Logged out successfully.";
}

window.location = '@aid.hubWsUrl/sso?returnToUrl=' +
encodeURIComponent(window.location) + '&title=' + title +
'&message=' + message + '&returnUrl=' + encodeURIComponent(link) +
'&returnTitle=' + returnTitle;
}
});
})();
</script>
</body>
</html>

0 comments on commit 5d2563d

Please sign in to comment.