From e4eb52e9ed8837ab62c03594eb14c54b39dcf52e Mon Sep 17 00:00:00 2001 From: TPS23 Date: Tue, 29 Aug 2017 11:51:46 -0400 Subject: [PATCH 1/2] login page now has link to about page --- app/security/auth0/views/login.scala.html | 106 ++++++++++++---------- 1 file changed, 60 insertions(+), 46 deletions(-) diff --git a/app/security/auth0/views/login.scala.html b/app/security/auth0/views/login.scala.html index 7ad3cf0..d1c740d 100644 --- a/app/security/auth0/views/login.scala.html +++ b/app/security/auth0/views/login.scala.html @@ -3,52 +3,66 @@ - - Log In - SPEW Web - - - - + - + 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 "); + + 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; + } + }); + })(); + + From 46174da316330358fdcb25fcd6c1d627c550361d Mon Sep 17 00:00:00 2001 From: TPS23 Date: Tue, 29 Aug 2017 12:19:29 -0400 Subject: [PATCH 2/2] more legible --- app/security/auth0/views/login.scala.html | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/app/security/auth0/views/login.scala.html b/app/security/auth0/views/login.scala.html index d1c740d..dab9113 100644 --- a/app/security/auth0/views/login.scala.html +++ b/app/security/auth0/views/login.scala.html @@ -12,18 +12,20 @@ (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"; + 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'; + loggedInUserId = '@userId'; + if (data && data.sso === true) { console.log('SSO: an Auth0 SSO session already exists');