Commit | Line | Data |
eb38afbc |
1 | [% WRAPPER header.tt |
2 | pagetitle = "Stemmaweb - Sign in" |
3 | applicationstyle = c.uri_for('/css/auth.css') |
4 | %] |
3fe754ff |
5 | |
6 | <meta name="google-signin-clientid" content="[% google_client_id %]" /> |
7 | <meta name="google-signin-scope" content="https://www.googleapis.com/auth/plus.profile.emails.read" /> |
8 | <meta name="google-signin-requestvisibleactions" content="http://schema.org/AddAction" /> |
9 | <meta name="google-signin-cookiepolicy" content="single_host_origin" /> |
10 | <meta name="google-signin-openidrealm" content="[% c.uri_for('/') %]" /> |
11 | <script src="https://apis.google.com/js/client:platform.js?onload=render" async defer> |
12 | </script> |
13 | <script> |
14 | /* Executed when the APIs finish loading */ |
15 | function render() { |
16 | |
17 | document.getElementById('signinButton').disabled = false; |
18 | var additionalParams = { |
19 | 'callback': googleSignIn |
20 | }; |
21 | |
22 | // Attach a click listener to a button to trigger the flow. |
23 | var signinButton = document.getElementById('signinButton'); |
24 | signinButton.addEventListener('click', function() { |
25 | gapi.auth.signIn(additionalParams); // Will use page level configuration |
26 | }); |
27 | |
eb38afbc |
28 | $('#login_actions').accordion(); |
29 | $('.login_button').button(); |
30 | $('#submit').button(); |
31 | |
32 | var status = '[% status_msg %]'; |
33 | if( status == 'Logged in!' ) { |
34 | setInterval( function ( e ) { |
35 | window.opener.location.reload(true); |
36 | window.close(); |
37 | e.preventDefault(); |
38 | }, 2000 ); |
39 | } |
3fe754ff |
40 | } |
41 | </script> |
42 | <script type="text/javascript"> |
85990daf |
43 | |
44 | function googleSignIn(authResult) { |
45 | if (authResult['status']['signed_in']) { |
3fe754ff |
46 | document.getElementById('signinButton').disabled = true; |
85990daf |
47 | gapi.client.load('plus', 'v1', function apiClientLoaded() { |
48 | gapi.client.plus.people.get({ userId: 'me'}).execute(function infoRetrieved(resp) { |
49 | var primaryEmail; |
50 | for (var i = 0; i < resp.emails.length; i++) { |
51 | if (resp.emails[i].type === 'account') { |
52 | primaryEmail = resp.emails[i].value; |
53 | } |
54 | } |
55 | |
56 | dataRetrieved(authResult, primaryEmail); |
57 | }); |
58 | }); |
59 | } else { |
60 | console.log("Error", authResult); |
61 | } |
62 | } |
63 | |
64 | function dataRetrieved(login, email) { |
65 | console.log(email); |
66 | console.log(login.id_token); |
67 | |
68 | document.getElementById('email').value = email; |
69 | document.getElementById('id_token').value = login.id_token; |
70 | document.getElementById('google_form').submit(); |
71 | } |
72 | |
eb38afbc |
73 | </script> |
74 | [% END %] |
75 | <div id="topbanner"> |
76 | <h1>Stemmaweb - Sign in</h1> |
77 | </div> |
78 | |
79 | <div id="login_status"> |
19262e3d |
80 | [% IF status_msg %] |
81 | <p>[% status_msg | html %]</p> |
82 | [% END %] |
83 | [% IF error_msg %] |
84 | <p class="error">[% error_msg | html %]</p> |
85 | [% END %] |
86 | |
87 | [% IF form.has_errors %] |
88 | <p class="error">Some fields had errors:</p> |
89 | |
90 | <ul class="errors"> |
91 | [% FOREACH msg IN form.errors %] |
92 | <li>[% msg | html %]</li> |
93 | [% END %] |
94 | </ul> |
95 | [% END %] |
eb38afbc |
96 | </div> |
97 | [% UNLESS status_msg == 'Logged in!' %] |
98 | <div id="login_actions"> |
99 | <h3><a href="#">Sign in with Google</a></h3> |
100 | <div> |
101 | <p>If you have a Google account, you may use it to sign into Stemmaweb.</p> |
3fe754ff |
102 | |
103 | <button disabled id="signinButton">Sign in with Google</button> |
85990daf |
104 | <form id="google_form" action="[% c.uri_for_action('/users/login') | html %]" method="post"> |
105 | <input id='email' name='email' value='' type='hidden' /> |
106 | <input id='id_token' name='id_token' value='' type='hidden' /> |
eb38afbc |
107 | </form> |
108 | </div> |
fd114bb4 |
109 | |
c2ab3497 |
110 | <h3><a href="#">Sign in with OpenID</a></h3> |
111 | <div> |
112 | <p>If you have an account with an <a href="http://openid.net/get-an-openid/" target="_blank">OpenID provider</a> (e.g. WordPress, Blogger, Flickr, Yahoo), you may use it to sign into Stemmaweb. |
113 | <form class="openid_form" method="post" action="[% c.uri_for_action('/users/login') | html %]" autocomplete="off"> |
114 | <input type="hidden" name="realm" value="openid"/> |
115 | <input type="text" name="openid_identifier" id="openid_input"/> |
116 | <input type="submit" class="login_button" id="login_openid" value="Sign in with OpenID"/> |
117 | </form> |
118 | </div> |
119 | |
b600c671 |
120 | [% UNLESS c.req.param('realm') == 'openid' %] |
eb38afbc |
121 | <h3><a href="#">Sign in with Stemmaweb</a></h3> |
122 | <div> |
123 | <p>If you do not have Google or another OpenID account, you may <a href="[% c.uri_for_action('/users/register') | html %]">register</a> for a user account here with its own password. Once you are registered, you can use this form to sign in.</p> |
124 | <form id="login_local_form" method="post" action="[% c.uri_for_action('/users/login') | html %]" autocomplete="off"> |
125 | <input type="hidden" name="realm" value="default"/> |
126 | [% userlabel = form.field('username').label('Email address') %] |
127 | [% form.field('username').render %] |
128 | [% form.field('password').render %] |
129 | |
130 | [% rememberlabel = form.field('remember').label('Remember me') %] |
131 | [% form.field('remember').render %] |
132 | |
133 | [% submitbutton = form.field('submit').value('Sign in with Stemmaweb') %] |
134 | [% form.field('submit').render %] |
135 | </form> |
136 | </div> |
137 | [% END %] |
138 | </div> |
139 | [% END %] |
85990daf |
140 | [% PROCESS footer.tt %] |