Changeset 35331 for main/trunk
- Timestamp:
- 2021-09-04T16:25:30+12:00 (3 years ago)
- Location:
- main/trunk/greenstone3/web/interfaces/default/transform
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/web/interfaces/default/transform/layouts/header.xsl
r35322 r35331 97 97 function gslogout(logout_action_url) { 98 98 if (googlesignin_client_id != '') { 99 google Signout();99 googleLogout(); 100 100 } 101 101 window.location = logout_action_url; … … 187 187 function googleSigninInit() { 188 188 gapi.load('auth2', function() { 189 auth2 = gapi.auth2.init({189 var auth2 = gapi.auth2.init({ 190 190 client_id: googlesignin_client_id, 191 191 //scope: 'email' // don't need to top up 'profile' with 'email' as not used client side (email is retrieved via GS3 Servlet) 192 }); 192 }) 193 .then(function() { 194 if (typeof optGoogleAuth2InitCallback === "function"){ 195 optGoogleAuth2InitCallback(); 196 } 197 }); 193 198 }); 194 199 } 195 200 196 function google Signout() {201 function googleLogout() { 197 202 var auth2 = gapi.auth2.getAuthInstance(); 198 auth2.signOut().then(function () { 203 // Use 'disconnect()' rather than 'signOut()' as this does a deeper logout 204 // that revokes the user's "Google granted" permission. 205 // This makes it easier, when using the same browser, to login into Greenstone3 206 // using a differeng Google sign-in account 207 208 auth2.disconnect().then(function () { 199 209 console.log("Google-authenticated User signed out"); 200 210 }); -
main/trunk/greenstone3/web/interfaces/default/transform/pages/login.xsl
r35322 r35331 56 56 </xsl:text> 57 57 </gsf:style> 58 58 59 <gsf:variable name="loginErrorMessage"><xsl:value-of select="/page/pageRequest/paramList/param[@name = 'loginMessage']/@value"/></gsf:variable> 60 61 <!-- 59 62 <xsl:if test="/page/pageRequest/paramList/param[@name = 'loginMessage']/@value"> 60 <div id="gs_error" class="ui-state-error ui-corner-all"> 61 <span class="ui-icon ui-icon-alert" style="float: left;"><xsl:text> </xsl:text></span><xsl:value-of select="/page/pageRequest/paramList/param[@name = 'loginMessage']/@value"/> 62 </div> 63 --> 64 <xsl:if test="$loginErrorMessage != ''"> 65 <div id="gs_error" class="ui-state-error ui-corner-all"> 66 <span class="ui-icon ui-icon-alert" style="float: left;"> 67 <xsl:text> </xsl:text> 68 </span> 69 <xsl:value-of select="$loginErrorMessage"/> 70 </div> 63 71 <br/> 64 72 </xsl:if> … … 126 134 function onGoogleSigninFailure(error) 127 135 { 128 console.error(error); 136 console.error(error); 137 $("#googlesignin_id_token").val(""); 129 138 } 130 139 131 140 function renderButton() 132 141 { 142 var auth2 = gapi.auth2.getAuthInstance(); 143 if ((gs.variables.loginErrorMessage != "") && auth2.isSignedIn.get()) { 144 145 // IF a Greenstone-login error is being shown on the page (loginErrorMessage) 146 // AND Google logged-in (isSignedIn) 147 // => THEN need to trigger a Google-logout, otherwise the 148 // the block of code below automatically tiggers a login 149 // attempt (using the Google credentials), which (if allowed to 150 // happen) then sets up a endless loop of login attempts 151 googleLogout(); 152 } 153 133 154 gapi.signin2.render('mygoogle-signin2', { 134 155 'scope': 'profile email', … … 142 163 } 143 164 144 window.onload = function(){165 function optGoogleAuth2InitCallback() { 145 166 if (gs.variables['googleSigninClientId']) { 167 // Only trigger the Google Signin button if a client-id has been set in servlet.xml 146 168 renderButton(); 147 169 }
Note:
See TracChangeset
for help on using the changeset viewer.