}, 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>
<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>
- <form method="post" action="[% c.uri_for_action('/users/login') | html %]" autocomplete="off">
- <input type="hidden" name="realm" value="openid"/>
- <input type="hidden" name="openid_identifier" value="https://www.google.com/accounts/o8/id"/>
- <input type="submit" class="login_button" id="#login_google" value="Sign in with Google"></input>
+ <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>
<h3><a href="#">Sign in with OpenID</a></h3>
<div>
<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.
- <form method="post" action="[% c.uri_for_action('/users/login') | html %]" autocomplete="off">
+ <form class="openid_form" method="post" action="[% c.uri_for_action('/users/login') | html %]" autocomplete="off">
<input type="hidden" name="realm" value="openid"/>
- <input type="text" name="openid_identifier"/>
- <input type="submit" class="login_button" id="#login_openid" value="Sign in with OpenID"/>
+ <input type="text" name="openid_identifier" id="openid_input"/>
+ <input type="submit" class="login_button" id="login_openid" value="Sign in with OpenID"/>
</form>
</div>
[% END %]
</div>
[% END %]
-[% PROCESS footer.tt %]
\ No newline at end of file
+[% PROCESS footer.tt %]