- Timestamp:
- 2023-03-02T23:09:46+13:00 (14 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/web/interfaces/default/transform/pages/login.xsl
r35820 r37391 11 11 12 12 <!-- use the 'main' layout --> 13 <xsl:i ncludehref="layouts/main.xsl"/>13 <xsl:import href="layouts/main.xsl"/> 14 14 15 15 <!-- set page title --> … … 48 48 input.gsloginform[type=submit] { 49 49 float: right; 50 margin-right: 10px;50 margin-right: 3px; 51 51 margin-top: 5px; 52 52 width: 80px; … … 95 95 <tr> 96 96 <td colspan="2"> 97 <input name="googleidentity-signin" type="hidden" value="0" /> 97 98 <input type="submit" class="gsloginform"><xsl:attribute name="value"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'login_b')"/></xsl:attribute></input> 98 99 </td> … … 106 107 <tr> 107 108 <td colspan="2"> 108 <input type="hidden" id="googlesignin_id_token" name="googlesignin_id_token"></input> 109 <gsf:div id="mygoogle-signin2" /> 109 <gsf:variable name="serlvetProtocol"><xsl:value-of select="/page/pageResponse/interfaceOptions/option[@name='servlet_protocol']/@value"/></gsf:variable> 110 <gsf:variable name="baseURL"><xsl:value-of select="/page/pageRequest/@baseURL"/></gsf:variable> 111 <gsf:variable name="redirectURL"><xsl:value-of select="/page/pageRequest/paramList/param[@name = 'redirectURL']/@value"/></gsf:variable> 112 <gsf:div id="g_id_onload" 113 data-client_id="{$googlesignin_client_id}" 114 data-ux_mode="redirect" 115 data-login_uri="{$servletProtocol}:{$baseURL}{$redirectURL}&googleidentity-signin=1"> 116 </gsf:div> 117 <gsf:div class="g_id_signin" data-type="standard"/> 118 110 119 </td> 111 120 </tr> … … 114 123 </table> 115 124 </form> 116 125 117 126 <gsf:variable name="googleSigninClientId"><xsl:value-of select="/page/pageResponse/interfaceOptions/option[@name = 'googlesignin_client_id']/@value"/></gsf:variable> 118 127 119 128 <gsf:script> 120 121 function onGoogleSigninSuccess(googleUser) 129 130 function decodeJwtResponse(jwt) { 131 // Split the JWT into its three parts 132 var parts = jwt.split('.'); 133 134 // Decode the header and payload parts using base64 135 var header = JSON.parse(atob(parts[0])); 136 var payload = JSON.parse(atob(parts[1])); 137 138 // Return an object containing the decoded header and payload 139 //return { 140 // header: header, 141 // payload: payload 142 //}; 143 return payload; 144 145 } 146 147 function googleSigninHandleCredentialResponseUNUSED(response) 122 148 { 149 console.log("onGoogleSignin() called"); 123 150 124 var google_fullname = googleUser.getBasicProfile().getName(); 151 const responsePayload = decodeJwtResponse(response.credential); 152 153 console.log("ID: " + responsePayload.sub); 154 console.log('Full Name: ' + responsePayload.name); 155 console.log('Given Name: ' + responsePayload.given_name); 156 console.log('Family Name: ' + responsePayload.family_name); 157 console.log("Image URL: " + responsePayload.picture); 158 console.log("Email: " + responsePayload.email); 159 console.log("Email verified: " + responsePayload.email_verified); 160 161 162 var google_fullname = responsePayload.name; 125 163 console.log('Google-authenicated login as: ' + google_fullname); 126 164 127 var googlesignin_id_token = googleUser.getAuthResponse().id_token;128 // console.log('Google ID Token: ' + googlesignin_id_token);165 //var googlesignin_id_token = googleUser.getAuthResponse().id_token; 166 // //console.log('Google ID Token: ' + googlesignin_id_token); 129 167 130 $("#googlesignin_id_token").val(googlesignin_id_token); 131 $("#login-form").submit(); 132 } 168 // $("#googlesignin_id_token").val(googlesignin_id_token); 169 // $("#login-form").submit(); 133 170 134 function onGoogleSigninFailure(error) 135 { 136 console.error(error); 137 $("#googlesignin_id_token").val(""); 138 } 139 140 function renderButton() 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 154 gapi.signin2.render('mygoogle-signin2', { 155 'scope': 'profile email', 156 'width': 240, 157 'height': 50, 158 'longtitle': true, 159 'theme': 'dark', 160 'onsuccess': onGoogleSigninSuccess, 161 'onfailure': onGoogleSigninFailure 162 }); 163 } 164 165 function optGoogleAuth2InitCallback() { 166 if (gs.variables['googleSigninClientId']) { 167 // Only trigger the Google Signin button if a client-id has been set in servlet.xml 168 renderButton(); 169 } 171 170 172 } 171 173
Note:
See TracChangeset
for help on using the changeset viewer.