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

Last change on this file since 37391 was 37391, checked in by davidb, 14 months ago

Changes related to shifting to the new GoogleIdentity API; also some tweaks to whitespace and tag-name construction using lower-case rather than uppercase tag names

  • Property svn:executable set to *
File size: 6.2 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 data-login_uri="{$servletProtocol}:{$baseURL}{$redirectURL}&amp;googleidentity-signin=1">
116 </gsf:div>
117 <gsf:div class="g_id_signin" data-type="standard"/>
118
119 </td>
120 </tr>
121 </xsl:if>
122
123 </table>
124 </form>
125
126 <gsf:variable name="googleSigninClientId"><xsl:value-of select="/page/pageResponse/interfaceOptions/option[@name = 'googlesignin_client_id']/@value"/></gsf:variable>
127
128 <gsf:script>
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)
148 {
149 console.log("onGoogleSignin() called");
150
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;
163 console.log('Google-authenicated login as: ' + google_fullname);
164
165 //var googlesignin_id_token = googleUser.getAuthResponse().id_token;
166 // //console.log('Google ID Token: ' + googlesignin_id_token);
167
168 // $("#googlesignin_id_token").val(googlesignin_id_token);
169 // $("#login-form").submit();
170
171
172 }
173
174 </gsf:script>
175
176 <script type="text/javascript">
177 <xsl:text disable-output-escaping="yes">
178 {
179 $("#loginTable input[name=\"username\"]").focus();
180 }
181 </xsl:text>
182 </script>
183 </xsl:template>
184</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.