2 pagetitle = "Stemmaweb - Sign in"
3 applicationstyle = c.uri_for('/css/auth.css')
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>
14 /* Executed when the APIs finish loading */
17 document.getElementById('signinButton').disabled = false;
18 var additionalParams = {
19 'callback': googleSignIn
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
28 $('#login_actions').accordion();
29 $('.login_button').button();
30 $('#submit').button();
32 var status = '[% status_msg %]';
33 if( status == 'Logged in!' ) {
34 setInterval( function ( e ) {
35 window.opener.location.reload(true);
42 <script type="text/javascript">
44 function googleSignIn(authResult) {
45 if (authResult['status']['signed_in']) {
46 document.getElementById('signinButton').disabled = true;
47 gapi.client.load('plus', 'v1', function apiClientLoaded() {
48 gapi.client.plus.people.get({ userId: 'me'}).execute(function infoRetrieved(resp) {
50 for (var i = 0; i < resp.emails.length; i++) {
51 if (resp.emails[i].type === 'account') {
52 primaryEmail = resp.emails[i].value;
56 dataRetrieved(authResult, primaryEmail);
60 console.log("Error", authResult);
64 function dataRetrieved(login, email) {
66 console.log(login.id_token);
68 document.getElementById('email').value = email;
69 document.getElementById('id_token').value = login.id_token;
70 document.getElementById('google_form').submit();
76 <h1>Stemmaweb - Sign in</h1>
79 <div id="login_status">
81 <p>[% status_msg | html %]</p>
84 <p class="error">[% error_msg | html %]</p>
87 [% IF form.has_errors %]
88 <p class="error">Some fields had errors:</p>
91 [% FOREACH msg IN form.errors %]
92 <li>[% msg | html %]</li>
97 [% UNLESS status_msg == 'Logged in!' %]
98 <div id="login_actions">
99 <h3><a href="#">Sign in with Google</a></h3>
101 <p>If you have a Google account, you may use it to sign into Stemmaweb.</p>
103 <button disabled id="signinButton">Sign in with Google</button>
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' />
110 <h3><a href="#">Sign in with OpenID</a></h3>
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"/>
120 [% UNLESS c.req.param('realm') == 'openid' %]
121 <h3><a href="#">Sign in with Stemmaweb</a></h3>
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 %]
130 [% rememberlabel = form.field('remember').label('Remember me') %]
131 [% form.field('remember').render %]
133 [% submitbutton = form.field('submit').value('Sign in with Stemmaweb') %]
134 [% form.field('submit').render %]
140 [% PROCESS footer.tt %]