summaryrefslogtreecommitdiffstats
path: root/extensions/BrowserID/template/en/default/hook/account/auth/login-small-additional_methods.html.tmpl
blob: 26d5ff609a457e0ee12ead37a36952335b23bbae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
[% IF Param('user_info_class').split(',').contains('BrowserID') %]
<script src="https://browserid.org/include.js" type="text/javascript"></script>

<script type="text/javascript">
function browserid_sign_in() {
    navigator.id.getVerifiedEmail(function(assertion) {
        if (assertion) {
            // This code will be invoked once the user has successfully
            // selected an email address they control to sign in with.
            var browseridForm = document.createElement('form');
            browseridForm.action = '[% login_target FILTER js %]';
            browseridForm.method = 'POST';
            browseridForm.style.display = 'none';
            
            var tokenField = document.createElement('input');
            tokenField.type = 'hidden';
            tokenField.name = 'token';
            tokenField.value = '[% issue_hash_token(['login']) FILTER js %]';
            browseridForm.appendChild(tokenField);

            var assertionField = document.createElement('input');
            assertionField.type = 'hidden';
            assertionField.name = 'browserid_assertion';
            assertionField.value = assertion;
            browseridForm.appendChild(assertionField);

            document.body.appendChild(browseridForm);
            browseridForm.submit();
            return true;
        }
    });
}
</script>

<img src="extensions/BrowserID/web/sign_in_orange.png" onclick="browserid_sign_in()" style="margin-bottom: -8px"> or
[% END %]