Ignore:
Timestamp:
Jan 20, 2013, 9:41:55 PM (11 years ago)
Author:
mistic100
Message:

clean code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/oAuth/auth.php

    r20293 r20301  
    99
    1010try {
     11  // inputs
    1112  if ( $provider == 'OpenID' and !isset($_GET['openid_identifier']) )
    1213  {
    13     throw new Exception('Invalid OpenID!');
     14    throw new Exception('Invalid OpenID!', 1003);
    1415  }
    1516 
    16   // inputs
    1717  if (
    1818    !array_key_exists($provider, $hybridauth_conf['providers'])
    1919    or !$hybridauth_conf['providers'][$provider]['enabled']
    2020  ) {
    21     throw new Exception('Hacking attempt!');
     21    throw new Exception('Hacking attempt!', 1002);
    2222  }
    23  
    24  
    2523 
    2624  $hybridauth = new Hybrid_Auth($hybridauth_conf);
     
    2927  if ($hybridauth->isConnectedWith($provider))
    3028  {
    31     $template->assign('AUTH_DONE', true);
    32    
    3329    $adapter = $hybridauth->getAdapter($provider);
    3430    $remote_user = $adapter->getUserProfile();
     
    6965  else if (isset($_GET['init_auth']))
    7066  {
    71     $params = array('hauth_return_to', get_absolute_root_url().OAUTH_PATH.'auth.php?provider='.$provider.'&auth_done=1');
     67    $params = array('hauth_return_to', get_absolute_root_url() . OAUTH_PATH . 'auth.php?provider='.$provider.'&auth_done=1');
    7268    if ($provider == 'OpenID')
    7369    {
     
    8379    $template->assign('LOADING', '&openid_identifier='.@$_GET['openid_identifier'].'&init_auth=1');
    8480  }
    85 }
    86 catch( Exception $e ){
    87   $template->assign('ERROR', $e->getMessage());
     81}
     82/*
     83 library errors :
     84     0 : Unspecified error
     85     1 : Hybriauth configuration error
     86     2 : Provider not properly configured
     87     3 : Unknown or disabled provider
     88     4 : Missing provider application credentials
     89     5 : Authentication aborded
     90 other errors :
     91  1002 : Invalid provider
     92  1003 : Missing openid_identifier
     93*/
     94catch (Exception $e) {
     95  switch ($e->getCode()) {
     96    case 5:
     97      $template->assign('ERROR', l10n('Authentication canceled')); break;
     98    default:
     99      $template->assign('ERROR', sprintf(l10n('An error occured, please contact the gallery owner. <i>Error code : %s</i>'), $e->getCode()));
     100  }
    88101}
    89102
     
    96109  'OAUTH_PATH' => OAUTH_PATH,
    97110  'PROVIDER' => $provider,
    98   'SELF_URL' => OAUTH_PATH.'auth.php?provider='.$provider,
     111  'SELF_URL' => OAUTH_PATH . 'auth.php?provider='.$provider,
    99112  ));
    100113
    101 $template->set_filename('index', realpath(OAUTH_PATH.'template/auth.tpl'));
     114$template->set_filename('index', realpath(OAUTH_PATH . 'template/auth.tpl'));
    102115$template->pparse('index');
    103116?>
Note: See TracChangeset for help on using the changeset viewer.