source: main/trunk/greenstone3/web/interfaces/default/transform/pages/login.xsl@ 37476

Last change on this file since 37476 was 37407, checked in by davidb, 15 months ago

More careful moitoring of login/logout args to avoid ending up with conflicting googleidentity-signin=1 AND logout= present at the same time

  • Property svn:executable set to *
File size: 6.6 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<!-- this page is used when the user clicks the Login button. If they have been directed to Login by trying to access a restricted page when they are not already logged in, then they will go to the Login section of authen.xsl -->
3<xsl:stylesheet version="1.0"
4 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5 xmlns:java="http://xml.apache.org/xslt/java"
6 xmlns:util="xalan://org.greenstone.gsdl3.util.XSLTUtil"
7 xmlns:gslib="http://www.greenstone.org/skinning"
8 xmlns:gsf="http://www.greenstone.org/greenstone3/schema/ConfigFormat"
9 extension-element-prefixes="java util"
10 exclude-result-prefixes="java util">
11
12 <!-- use the 'main' layout -->
13 <xsl:import href="layouts/main.xsl"/>
14
15 <!-- set page title -->
16 <xsl:template name="pageTitle"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'login_b')"/></xsl:template>
17
18 <!-- set page breadcrumbs -->
19 <xsl:template name="breadcrumbs"><gslib:siteLink/></xsl:template>
20
21 <!-- the page content -->
22 <xsl:template match="/page">
23 <gsf:style>
24 <xsl:text disable-output-escaping="yes">
25 /* Based on: https://stackoverflow.com/questions/2812770/add-centered-text-to-the-middle-of-a-horizontal-rule */
26.hr-with-text {
27 display: flex;
28 align-items: center;
29 text-align: center;
30}
31
32.hr-with-text::before,
33.hr-with-text::after {
34 content: '';
35 flex: 1;
36 border-bottom: 1px solid #000;
37}
38
39.hr-with-text:not(:empty)::before {
40 margin-right: .25em;
41}
42
43.hr-with-text:not(:empty)::after {
44 margin-left: .25em;
45}
46
47
48input.gsloginform[type=submit] {
49 float: right;
50 margin-right: 3px;
51 margin-top: 5px;
52 width: 80px;
53 height: 30px;
54}
55
56 </xsl:text>
57 </gsf:style>
58
59 <gsf:variable name="loginErrorMessage"><xsl:value-of select="/page/pageRequest/paramList/param[@name = 'loginMessage']/@value"/></gsf:variable>
60
61 <!--
62 <xsl:if test="/page/pageRequest/paramList/param[@name = 'loginMessage']/@value">
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>
71 <br/>
72 </xsl:if>
73 <form method="POST"
74 id="login-form"
75 action="{/page/pageRequest/paramList/param[@name = 'redirectURL']/@value}">
76 <table id="loginTable">
77 <tr>
78 <td colspan="2">
79 <input type="text" name="username" style="width:95%;" autocomplete="username">
80 <xsl:attribute name="placeholder">
81 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.username')"/>
82 </xsl:attribute>
83 </input>
84 </td>
85 </tr>
86 <tr>
87 <td colspan="2">
88 <input type="password" name="password" style="width:95%;" autocomplete="current-password">
89 <xsl:attribute name="placeholder">
90 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.password')"/>
91 </xsl:attribute>
92 </input>
93 </td>
94 </tr>
95 <tr>
96 <td colspan="2">
97 <input name="googleidentity-signin" type="hidden" value="0" />
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>
99 </td>
100 </tr>
101 <xsl:if test="$googlesignin_client_id">
102 <tr>
103 <td colspan="2">
104 <div class="hr-with-text">or</div>
105 </td>
106 </tr>
107 <tr>
108 <td colspan="2">
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 <xsl:attribute name="data-login_uri">
116 <xsl:call-template name="generateGoogleIdentityLoginURL">
117 <xsl:with-param name="servletProtocol" select="$servletProtocol"></xsl:with-param>
118 <xsl:with-param name="baseURL" select="$baseURL"></xsl:with-param>
119 <xsl:with-param name="redirectURL" select="$redirectURL"></xsl:with-param>
120 </xsl:call-template>
121
122 </xsl:attribute>
123
124
125 </gsf:div>
126
127 <gsf:div class="g_id_signin" data-type="standard"/>
128
129 </td>
130 </tr>
131 </xsl:if>
132
133 </table>
134 </form>
135
136 <gsf:variable name="googleSigninClientId"><xsl:value-of select="/page/pageResponse/interfaceOptions/option[@name = 'googlesignin_client_id']/@value"/></gsf:variable>
137
138 <gsf:script>
139
140 function decodeJwtResponse(jwt) {
141 // Split the JWT into its three parts
142 var parts = jwt.split('.');
143
144 // Decode the header and payload parts using base64
145 var header = JSON.parse(atob(parts[0]));
146 var payload = JSON.parse(atob(parts[1]));
147
148 // Return an object containing the decoded header and payload
149 //return {
150 // header: header,
151 // payload: payload
152 //};
153 return payload;
154
155 }
156
157 function googleSigninHandleCredentialResponseUNUSED(response)
158 {
159 console.log("onGoogleSignin() called");
160
161 const responsePayload = decodeJwtResponse(response.credential);
162
163 console.log("ID: " + responsePayload.sub);
164 console.log('Full Name: ' + responsePayload.name);
165 console.log('Given Name: ' + responsePayload.given_name);
166 console.log('Family Name: ' + responsePayload.family_name);
167 console.log("Image URL: " + responsePayload.picture);
168 console.log("Email: " + responsePayload.email);
169 console.log("Email verified: " + responsePayload.email_verified);
170
171
172 var google_fullname = responsePayload.name;
173 console.log('Google-authenicated login as: ' + google_fullname);
174
175 //var googlesignin_id_token = googleUser.getAuthResponse().id_token;
176 // //console.log('Google ID Token: ' + googlesignin_id_token);
177
178 // $("#googlesignin_id_token").val(googlesignin_id_token);
179 // $("#login-form").submit();
180
181
182 }
183
184 </gsf:script>
185
186 <script type="text/javascript">
187 <xsl:text disable-output-escaping="yes">
188 {
189 $("#loginTable input[name=\"username\"]").focus();
190 }
191 </xsl:text>
192 </script>
193 </xsl:template>
194</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.