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:include 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 |
|
---|
48 | input.gsloginform[type=submit] {
|
---|
49 | float: right;
|
---|
50 | margin-right: 10px;
|
---|
51 | margin-top: 5px;
|
---|
52 | width: 80px;
|
---|
53 | height: 30px;
|
---|
54 | }
|
---|
55 |
|
---|
56 | </xsl:text>
|
---|
57 | </gsf:style>
|
---|
58 |
|
---|
59 | <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 | <br/>
|
---|
64 | </xsl:if>
|
---|
65 | <form method="POST"
|
---|
66 | id="login-form"
|
---|
67 | action="{/page/pageRequest/paramList/param[@name = 'redirectURL']/@value}">
|
---|
68 | <table id="loginTable">
|
---|
69 | <tr>
|
---|
70 | <td colspan="2">
|
---|
71 | <input type="text" name="username" style="width:95%;">
|
---|
72 | <xsl:attribute name="placeholder">
|
---|
73 | <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.username')"/>
|
---|
74 | </xsl:attribute>
|
---|
75 | </input>
|
---|
76 | </td>
|
---|
77 | </tr>
|
---|
78 | <tr>
|
---|
79 | <td colspan="2">
|
---|
80 | <input type="password" name="password" style="width:95%;">
|
---|
81 | <xsl:attribute name="placeholder">
|
---|
82 | <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.password')"/>
|
---|
83 | </xsl:attribute>
|
---|
84 | </input>
|
---|
85 | </td>
|
---|
86 | </tr>
|
---|
87 | <tr>
|
---|
88 | <td colspan="2">
|
---|
89 | <input type="submit" class="gsloginform"><xsl:attribute name="value"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'login_b')"/></xsl:attribute></input>
|
---|
90 | </td>
|
---|
91 | </tr>
|
---|
92 | <xsl:if test="$googlesignin_client_id">
|
---|
93 | <tr>
|
---|
94 | <td colspan="2">
|
---|
95 | <div class="hr-with-text">or</div>
|
---|
96 | </td>
|
---|
97 | </tr>
|
---|
98 | <tr>
|
---|
99 | <td colspan="2">
|
---|
100 | <input type="hidden" id="googlesignin_id_token" name="googlesignin_id_token"></input>
|
---|
101 | <gsf:div id="mygoogle-signin2" />
|
---|
102 | </td>
|
---|
103 | </tr>
|
---|
104 | </xsl:if>
|
---|
105 |
|
---|
106 | </table>
|
---|
107 | </form>
|
---|
108 |
|
---|
109 | <gsf:variable name="googleSigninClientId"><xsl:value-of select="/page/pageResponse/interfaceOptions/option[@name = 'googlesignin_client_id']/@value"/></gsf:variable>
|
---|
110 |
|
---|
111 | <gsf:script>
|
---|
112 |
|
---|
113 | function onGoogleSigninSuccess(googleUser)
|
---|
114 | {
|
---|
115 |
|
---|
116 | var google_fullname = googleUser.getBasicProfile().getName();
|
---|
117 | console.log('Google-authenicated login as: ' + google_fullname);
|
---|
118 |
|
---|
119 | var googlesignin_id_token = googleUser.getAuthResponse().id_token;
|
---|
120 | //console.log('Google ID Token: ' + googlesignin_id_token);
|
---|
121 |
|
---|
122 | $("#googlesignin_id_token").val(googlesignin_id_token);
|
---|
123 | $("#login-form").submit();
|
---|
124 | }
|
---|
125 |
|
---|
126 | function onGoogleSigninFailure(error)
|
---|
127 | {
|
---|
128 | console.error(error);
|
---|
129 | }
|
---|
130 |
|
---|
131 | function renderButton()
|
---|
132 | {
|
---|
133 | gapi.signin2.render('mygoogle-signin2', {
|
---|
134 | 'scope': 'profile email',
|
---|
135 | 'width': 240,
|
---|
136 | 'height': 50,
|
---|
137 | 'longtitle': true,
|
---|
138 | 'theme': 'dark',
|
---|
139 | 'onsuccess': onGoogleSigninSuccess,
|
---|
140 | 'onfailure': onGoogleSigninFailure
|
---|
141 | });
|
---|
142 | }
|
---|
143 |
|
---|
144 | window.onload = function() {
|
---|
145 | if (gs.variables['googleSigninClientId']) {
|
---|
146 | renderButton();
|
---|
147 | }
|
---|
148 | }
|
---|
149 |
|
---|
150 | </gsf:script>
|
---|
151 |
|
---|
152 | <script type="text/javascript">
|
---|
153 | <xsl:text disable-output-escaping="yes">
|
---|
154 | {
|
---|
155 | $("#loginTable input[name=\"username\"]").focus();
|
---|
156 | }
|
---|
157 | </xsl:text>
|
---|
158 | </script>
|
---|
159 | </xsl:template>
|
---|
160 | </xsl:stylesheet>
|
---|