Changeset 21584


Ignore:
Timestamp:
Mar 15, 2013, 6:43:07 PM (7 years ago)
Author:
mistic100
Message:

don't delete keys when the provider is removed, hide fieldset when no provider active, use jQuery instead of $

Location:
extensions/oAuth
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • extensions/oAuth/admin/providers.php

    r20620 r21584  
    1111  foreach ($_POST['providers'] as $id => $data)
    1212  {
    13     $error = false;
    1413    $data['enabled'] = $data['enabled']=='true';
    1514   
     
    2120      ) {
    2221        array_push($page['errors'], sprintf(l10n('%s: invalid keys'), $PROVIDERS_CONFIG[$id]['provider_name']));
    23         $error = true;
    2422      }
    2523    }
    26     else
    27     {
    28       unset($data['keys']);
    29     }
    3024   
    31     if ( ($id=='Wordpress' or $id=='Flickr') and $data['enabled'] and !@$providers['OpenID']['enabled'] )
     25    if ( ($id=='Wordpress' or $id=='Flickr') and $data['enabled'] and !@$providers['OpenID']['enabled'] ) // in the template, OpenID must be before other OpenID based providers
    3226    {
    3327      array_push($page['errors'], sprintf(l10n('OpenID must be enabled in order to use %s authentication'), $id));
    34       $error = true;
    3528    }
    3629   
  • extensions/oAuth/include/providers_stats.inc.php

    r20368 r21584  
    77    'require_client_id' => true,
    88    'new_app_link'      => 'https://developers.facebook.com/apps',
    9     'userguide_section' => 'http://hybridauth.sourceforge.net/userguide/IDProvider_info_Facebook.html',
    109    'scope'             => 'email',
    1110  ),
     
    1716    'require_client_id' => true,
    1817    'new_app_link'      => 'https://code.google.com/apis/console',
    19     'userguide_section' => 'http://hybridauth.sourceforge.net/userguide/IDProvider_info_Google.html',
    2018    'scope'             => 'https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email',
    2119  ),
     
    2624    'require_client_id' => true,
    2725    'new_app_link'      => 'http://instagram.com/developer/clients/manage',
    28     'userguide_section' => null,
    2926  ),
    3027  'LinkedIn' => array(
     
    3229    'provider_name'     => 'LinkedIn',
    3330    'new_app_link'      => 'https://www.linkedin.com/secure/developer',
    34     'userguide_section' => 'http://hybridauth.sourceforge.net/userguide/IDProvider_info_LinkedIn.html',
    3531  ),
    3632  'Tumblr' => array(
     
    3834    'provider_name'     => 'Tumblr',
    3935    'new_app_link'      => 'http://www.tumblr.com/oauth/apps',
    40     'userguide_section' => 'http://hybridauth.sourceforge.net/userguide/IDProvider_info_Tumblr.html',
    4136  ),
    4237  'Twitter' => array(
     
    4439    'provider_name'     => 'Twitter',
    4540    'new_app_link'      => 'https://dev.twitter.com/apps',
    46     'userguide_section' => 'http://hybridauth.sourceforge.net/userguide/IDProvider_info_Twitter.html',
    4741  ),
    4842  'Live' => array(
     
    5145    'require_client_id' => true,
    5246    'new_app_link'      => 'https://manage.dev.live.com/ApplicationOverview.aspx',
    53     'userguide_section' => 'http://hybridauth.sourceforge.net/userguide/IDProvider_info_Live.html',
    5447  ),
    5548  'Yahoo' => array(
     
    5750    'provider_name'     => 'Yahoo!',
    5851    'new_app_link'      => 'https://developer.apps.yahoo.com/projects/',
    59     'userguide_section' => 'http://hybridauth.sourceforge.net/userguide/IDProvider_info_Yahoo.html',
    6052  ),
    6153  'OpenID' => array(
     
    6355    'provider_name'     => 'OpenID',
    6456    'new_app_link'      => null,
    65     'userguide_section' => 'http://hybridauth.sourceforge.net/userguide/IDProvider_info_OpenID.html',
    6657  ),
    6758  'Flickr' => array(
     
    6960    'provider_name'     => 'Flickr',
    7061    'new_app_link'      => null,
    71     'userguide_section' => 'http://hybridauth.sourceforge.net/userguide/IDProvider_info_OpenID.html',
    7262  ),
    7363  'Wordpress' => array(
     
    7565    'provider_name'     => 'Wordpress',
    7666    'new_app_link'      => null,
    77     'userguide_section' => 'http://hybridauth.sourceforge.net/userguide/IDProvider_info_OpenID.html',
    7867  ),
    7968);
  • extensions/oAuth/include/public_events.inc.php

    r21325 r21584  
    6161      $adapter = $hybridauth->authenticate($provider);
    6262      $remote_user = $adapter->getUserProfile();
     63     
     64      // security, check remote identifier
     65      if ($remote_user->identifier != $user_identifier)
     66      {
     67        pwg_unset_session_var('oauth_new_user');
     68        throw new Exception('Hacking attempt!');
     69      }
    6370   
    6471      $template->assign(array(
     
    7380     
    7481      $oauth_id = $provider.'---'.$remote_user->identifier;
    75      
    76       // security, check remote identifier
    77       if ($remote_user->identifier != $user_identifier)
    78       {
    79         pwg_unset_session_var('oauth_new_user');
    80         throw new Exception('Hacking attempt!');
    81       }
    8282     
    8383      // form submited
     
    9696          $user_id = get_userid($_POST['login']);
    9797         
    98           // udpdate oauth field
     98          // update oauth field
    9999          $query = '
    100100UPDATE '.USERS_TABLE.'
     
    235235  $template->assign('REDIRECT_TO', get_gallery_home_url());
    236236 
    237   $template->set_prefilter('menubar', 'oauth_add_menubar_buttons');
     237  $template->set_prefilter('menubar', 'oauth_add_menubar_buttons_prefilter');
    238238}
    239239
     
    254254  $add = 'disabled="disabled" ';
    255255  $script = '
    256 {footer_script}{literal}
     256{footer_script}
    257257jQuery("input[type=\'password\'], input[name=\'send_password_by_mail\']").parent("li").css("display", "none");
    258 {/literal}{/footer_script}';
     258{/footer_script}';
    259259
    260260  $content = str_replace($search, $search.$add, $content);
     
    269269}
    270270
    271 function oauth_add_menubar_buttons($content)
     271function oauth_add_menubar_buttons_prefilter($content)
    272272{
    273273  $search = '{include file=$block->template|@get_extent:$id }';
  • extensions/oAuth/template/identification_common.tpl

    r20620 r21584  
    4141
    4242// click on a button
    43 $("a.oauth").click(function() {
    44   var idp = $(this).data('idp');
     43jQuery("a.oauth").click(function() {
     44  var idp = jQuery(this).data('idp');
    4545 
    4646  switch(idp) {
     
    4949{/literal}
    5050        case 'OpenID':
    51           $("#openid_label").html('{'Please enter your OpenID URL'|@translate|escape:javascript}'); break;
     51          jQuery("#openid_label").html('{'Please enter your OpenID URL'|@translate|escape:javascript}'); break;
    5252        case 'Wordpress': case 'Flickr':
    53           $("#openid_label").html('{'Please enter your username'|@translate|escape:javascript}'); break;
     53          jQuery("#openid_label").html('{'Please enter your username'|@translate|escape:javascript}'); break;
    5454      }
    5555     
    56       $("#openid_form").css('background-color', $("#the_page #content").css('background-color'));
    57       $("#openid_form .oauth_38px").removeClass().addClass("oauth_38px " + idp.toLowerCase());
    58       $("#openid_form h3").html(idp);
    59       $("#openid_form").data('idp', idp);
     56      jQuery("#openid_form").css('background-color', $("#the_page #content").css('background-color'));
     57      jQuery("#openid_form .oauth_38px").removeClass().addClass("oauth_38px " + idp.toLowerCase());
     58      jQuery("#openid_form h3").html(idp);
     59      jQuery("#openid_form").data('idp', idp);
    6060{literal} 
    61       $.colorbox({
     61      jQuery.colorbox({
    6262        inline:true,
    6363        href:"#openid_form",
    6464        initialWidth:0,
    6565        initialHeight:0,
    66         onComplete:function(){ $.colorbox.resize({speed:0}) } // prevent misalignement when icon not loaded
     66        onComplete:function(){ jQuery.colorbox.resize({speed:0}) } // prevent misalignement when icon not loaded
    6767      })
    6868      break;
     
    7777});
    7878
    79 $("#openid_form").submit(function() {
    80   var idp = $(this).data('idp');
    81   var oi = $("#openid_form input[name='openid_identifier']").val();
    82   $("#openid_form input[name='openid_identifier']").val('');
     79jQuery("#openid_form").submit(function() {
     80  var idp = jQuery(this).data('idp');
     81  var oi = jQuery("#openid_form input[name='openid_identifier']").val();
     82  jQuery("#openid_form input[name='openid_identifier']").val('');
    8383 
    84   $("#openid_label").removeClass('error');
     84  jQuery("#openid_label").removeClass('error');
    8585  if (!oi) {
    86     $("#openid_label").addClass('error');
     86    jQuery("#openid_label").addClass('error');
    8787    return false;
    8888  }
     
    9595  open_auth("{$OAUTH_URL}OpenID&openid_identifier="+ encodeURI(oi));
    9696{literal}
    97   $.colorbox.close();
     97  jQuery.colorbox.close();
    9898  return false;
    9999});
    100100
    101 $("#openid_cancel").click(function() {
    102   $("#openid_label").removeClass('error');
    103   $.colorbox.close();
     101jQuery("#openid_cancel").click(function() {
     102  jQuery("#openid_label").removeClass('error');
     103  jQuery.colorbox.close();
    104104  return false;
    105105});
  • extensions/oAuth/template/identification_menubar.tpl

    r20620 r21584  
    1 {if $id == "mbIdentification" and isset($U_LOGIN)}
     1{if $id == "mbIdentification" and isset($U_LOGIN) and count($PROVIDERS)}
    22  {if not $OAUTH_JS_LOADED}
    33    {assign var=OAUTH_JS_LOADED value=true}
  • extensions/oAuth/template/identification_page.tpl

    r20620 r21584  
    1 {if not $OAUTH_JS_LOADED}
    2   {assign var=OAUTH_JS_LOADED value=true}
    3   {include file=$OAUTH_ABS_PATH|cat:'template/identification_common.tpl'}
     1{if count($PROVIDERS)}
     2  {if not $OAUTH_JS_LOADED}
     3    {assign var=OAUTH_JS_LOADED value=true}
     4    {include file=$OAUTH_ABS_PATH|cat:'template/identification_common.tpl'}
     5  {/if}
     6  {html_style}{literal}
     7    #oauth_wrap .oauth {
     8      margin:0 2px;
     9    }
     10  {/literal}{/html_style}
     11   
     12  <fieldset style="text-align:center;" id="oauth_wrap">
     13    <legend>{'Or sign in with'|@translate}</legend>
     14   
     15  {foreach from=$PROVIDERS item=provider key=p}{strip}
     16    <a href="#" class="oauth oauth_{$oauth.identification_icon} {$p|strtolower}" data-idp="{$p}" title="{$provider.name}"></a>
     17  {/strip}{/foreach}
     18  </fieldset>
    419{/if}
    5 {html_style}{literal}
    6   #oauth_wrap .oauth {
    7     margin:0 2px;
    8   }
    9 {/literal}{/html_style}
    10  
    11 <fieldset style="text-align:center;" id="oauth_wrap">
    12   <legend>{'Or sign in with'|@translate}</legend>
    13  
    14 {foreach from=$PROVIDERS item=provider key=p}{strip}
    15   <a href="#" class="oauth oauth_{$oauth.identification_icon} {$p|strtolower}" data-idp="{$p}" title="{$provider.name}"></a>
    16 {/strip}{/foreach}
    17 </fieldset>
Note: See TracChangeset for help on using the changeset viewer.