Ignore:
Timestamp:
Jan 11, 2014, 1:27:14 AM (10 years ago)
Author:
mistic100
Message:

add Persona authentification

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/oAuth/template/identification_common.tpl

    r26604 r26605  
    33{combine_script id='jquery.colorbox' load='footer' require='jquery' path='themes/default/js/plugins/jquery.colorbox.min.js'}
    44{combine_css id='colorbox' path="themes/default/js/plugins/colorbox/style2/colorbox.css"}
     5
     6{if $OAUTH.providers.Persona.enabled}
     7  {combine_script id='persona' path='https://login.persona.org/include.js' load='footer'}
     8{/if}
    59
    610{html_style}
     
    3135
    3236// click on a button
    33 jQuery('a.oauth').click(function(e) {
     37jQuery('a.oauth:not(.persona)').click(function(e) {
    3438  e.preventDefault();
    3539 
     
    100104  jQuery.colorbox.close();
    101105});
     106
     107{if $OAUTH.providers.Persona.enabled}
     108jQuery('a.oauth.persona').click(function(e) {
     109  e.preventDefault();
     110  navigator.id.request();
     111});
     112
     113jQuery('a[href$="act=logout"]').click(function(e) {
     114  e.preventDefault();
     115  navigator.id.logout();
     116});
     117
     118navigator.id.watch({
     119  loggedInUser: {if not empty($OAUTH.persona_email)}'{$OAUTH.persona_email}'{else}null{/if},
     120 
     121  onlogin: function(assertion) {
     122    jQuery.ajax({
     123      type: 'POST',
     124      url: '{$OAUTH.u_login}Persona',
     125      dataType: 'json',
     126      data: { assertion: assertion },
     127      success: function(data) {
     128        oauth_redirect(data.redirect_to);
     129      },
     130      error: function() {
     131        alert('Unknown error');
     132      }
     133    });
     134  },
     135 
     136  onlogout: function() {
     137    window.location.href = '{$U_LOGOUT}';
     138  }
     139});
     140{/if}
    102141{/footer_script}
    103142
Note: See TracChangeset for help on using the changeset viewer.