+[% WRAPPER header.tt
+ pagetitle = "Stemmaweb - Sign in"
+ applicationstyle = c.uri_for('/css/auth.css')
+%]
+ <script type="text/javascript">
+$(document).ready(function() {
+ // call out to load the directory div
+ $('#login_actions').accordion();
+ $('.login_button').button();
+ $('#submit').button();
+
+ var status = '[% status_msg %]';
+ if( status == 'Logged in!' ) {
+ setInterval( function ( e ) {
+ window.opener.location.reload(true);
+ window.close();
+ e.preventDefault();
+ }, 2000 );
+ }
+});
+
+ function googleSignIn(authResult) {
+ if (authResult['status']['signed_in']) {
+ document.getElementById('signinButton').setAttribute('style', 'display:none');
+ gapi.client.load('plus', 'v1', function apiClientLoaded() {
+ gapi.client.plus.people.get({ userId: 'me'}).execute(function infoRetrieved(resp) {
+ var primaryEmail;
+ for (var i = 0; i < resp.emails.length; i++) {
+ if (resp.emails[i].type === 'account') {
+ primaryEmail = resp.emails[i].value;
+ }
+ }
+
+ dataRetrieved(authResult, primaryEmail);
+ });
+ });
+ } else {
+ console.log("Error", authResult);
+ }
+ }
+
+ function dataRetrieved(login, email) {
+ console.log(email);
+ console.log(login.id_token);
+
+ document.getElementById('email').value = email;
+ document.getElementById('id_token').value = login.id_token;
+ document.getElementById('google_form').submit();
+ }
+
+ </script>
+ <script src="https://apis.google.com/js/client:platform.js" async defer></script>
+[% END %]
+ <div id="topbanner">
+ <h1>Stemmaweb - Sign in</h1>
+ </div>
+
+<div id="login_status">
[% IF status_msg %]
<p>[% status_msg | html %]</p>
[% END %]
[% END %]
</ul>
[% END %]
-
- <form method="post" action="[% c.uri_for_action('/users/login').hostless | html %]" autocomplete="off">
-
- <select name="realm">
- <option value="default">Local</option>
- <option value="openid">OpenID</option>
- </select>
-
- [% form.field('openid_identifier').render %]
-<!--
-<div id="field-openid-identifier">
-<label for="openid_identifier">OpenID login/url</label>
-<input type="text" name="openid_identifier" id="openid_identifier"/><br>
</div>
--->
- [% form.field('username').render %]
- [% form.field('password').render %]
-
- [% form.field('remember').render %]
- [% form.field('submit').render %]
+[% UNLESS status_msg == 'Logged in!' %]
+<div id="login_actions">
+ <h3><a href="#">Sign in with Google</a></h3>
+ <div>
+ <p>If you have a Google account, you may use it to sign into Stemmaweb.</p>
+ <span id="signinButton">
+ <span
+ class="g-signin"
+ data-callback="googleSignIn"
+ data-clientid="577442226093-pi2ud795g49ibip78bgfoabhl4kdrguc.apps.googleusercontent.com"
+ data-cookiepolicy="single_host_origin"
+ data-requestvisibleactions="http://schema.org/AddAction"
+ data-scope="https://www.googleapis.com/auth/plus.profile.emails.read"
+ data-openidrealm="http://sherlock.scsys.co.uk:3000/"
+ >
+ </span>
+ </span>
+ <form id="google_form" action="[% c.uri_for_action('/users/login') | html %]" method="post">
+ <input id='email' name='email' value='' type='hidden' />
+ <input id='id_token' name='id_token' value='' type='hidden' />
+ </form>
+ </div>
- </form>
\ No newline at end of file
+[% UNLESS c.req.param('realm') == 'openid' %]
+ <h3><a href="#">Sign in with Stemmaweb</a></h3>
+ <div>
+ <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>
+ <form id="login_local_form" method="post" action="[% c.uri_for_action('/users/login') | html %]" autocomplete="off">
+ <input type="hidden" name="realm" value="default"/>
+ [% userlabel = form.field('username').label('Email address') %]
+ [% form.field('username').render %]
+ [% form.field('password').render %]
+
+ [% rememberlabel = form.field('remember').label('Remember me') %]
+ [% form.field('remember').render %]
+
+ [% submitbutton = form.field('submit').value('Sign in with Stemmaweb') %]
+ [% form.field('submit').render %]
+ </form>
+ </div>
+[% END %]
+</div>
+[% END %]
+[% PROCESS footer.tt %]