Development

Changeset 7745

You must first sign up to be able to contribute.

Changeset 7745

Show
Ignore:
Timestamp:
03/05/08 12:05:33 (2 years ago)
Author:
fabien
Message:

sfGuardPlugin: updated 1.1 branch

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfGuardPlugin/branches/1.1/README

    r7657 r7745  
    366366== TODO == 
    367367 
    368   * finish the `promote_super_user` task 
    369368  * finish the `getPassword` method 
    370369  * add support for HTTP Basic authentication 
     
    372371== Changelog == 
    373372 
     373=== 2.1.0-PRE === 
     374 
     375  * fabien: added forms (migrated sfGuardAuth) 
     376  * fabien: added guard:create_user and guard:promote tasks 
     377 
    374378=== 2.0.0 === 
    375379 
  • plugins/sfGuardPlugin/branches/1.1/config/schema.yml

    r7634 r7745  
    11propel: 
    22  _attributes:      { package: plugins.sfGuardPlugin.lib.model } 
    3    
     3 
    44  sf_guard_group: 
    55    _attributes:    { phpName: sfGuardGroup } 
     
    77    name:           { type: varchar, size: 255, required: true, index: unique } 
    88    description:    { type: longvarchar } 
    9    
     9 
    1010  sf_guard_permission: 
    1111    _attributes:    { phpName: sfGuardPermission } 
     
    1313    name:           { type: varchar, size: 255, required: true, index: unique } 
    1414    description:    { type: longvarchar } 
    15    
     15 
    1616  sf_guard_group_permission: 
    1717    _attributes:    { phpName: sfGuardGroupPermission } 
    1818    group_id:       { type: integer, primaryKey: true, required: true, foreignTable: sf_guard_group, foreignReference: id, onDelete: cascade } 
    1919    permission_id:  { type: integer, primaryKey: true, required: true, foreignTable: sf_guard_permission, foreignReference: id, onDelete: cascade } 
    20    
     20 
    2121  sf_guard_user: 
    2222    _attributes:    { phpName: sfGuardUser } 
     
    3030    is_active:      { type: boolean, required: true, default: 1 } 
    3131    is_super_admin: { type: boolean, required: true, default: 0 } 
    32    
     32 
    3333  sf_guard_user_permission: 
    3434    _attributes:    { phpName: sfGuardUserPermission } 
    3535    user_id:        { type: integer, primaryKey: true, required: true, foreignTable: sf_guard_user, foreignReference: id, onDelete: cascade } 
    3636    permission_id:  { type: integer, primaryKey: true, required: true, foreignTable: sf_guard_permission, foreignReference: id, onDelete: cascade } 
    37    
     37 
    3838  sf_guard_user_group: 
    3939    _attributes:    { phpName: sfGuardUserGroup } 
    4040    user_id:        { type: integer, primaryKey: true, required: true, foreignTable: sf_guard_user, foreignReference: id, onDelete: cascade } 
    4141    group_id:       { type: integer, primaryKey: true, required: true, foreignTable: sf_guard_group, foreignReference: id, onDelete: cascade } 
    42      
     42 
    4343  sf_guard_remember_key: 
    4444    _attributes:    { phpName: sfGuardRememberKey } 
  • plugins/sfGuardPlugin/branches/1.1/lib/user/sfGuardSecurityUser.class.php

    r7634 r7745  
    2020  private $user = null; 
    2121 
     22  public function getReferer($default) 
     23  { 
     24    $referer = $this->getAttribute('referer', $default); 
     25    $this->getAttributeHolder()->remove('referer'); 
     26 
     27    return $referer; 
     28  } 
     29 
     30  public function setReferer($referer) 
     31  { 
     32    if (!$this->hasAttribute('referer')) 
     33    { 
     34      $this->setAttribute('referer', $referer); 
     35    } 
     36  } 
     37 
    2238  public function hasCredential($credential, $useAnd = true) 
    2339  { 
  • plugins/sfGuardPlugin/branches/1.1/modules/sfGuardAuth/lib/BasesfGuardAuthActions.class.php

    r7634 r7745  
    1818class BasesfGuardAuthActions extends sfActions 
    1919{ 
    20   public function executeSignin(
     20  public function executeSignin($request
    2121  { 
    2222    $user = $this->getUser(); 
    23     if ($this->getRequest()->getMethod() == sfRequest::POST
     23    if ($user->isAuthenticated()
    2424    { 
    25       $referer = $user->getAttribute('referer', $this->getRequest()->getReferer()); 
    26       $user->getAttributeHolder()->remove('referer'); 
     25      return $this->redirect('@homepage'); 
     26    } 
    2727 
    28       $signin_url = sfConfig::get('app_sf_guard_plugin_success_signin_url', $referer); 
     28    $this->form = new sfGuardFormSignin(); 
    2929 
    30       $this->redirect('' != $signin_url ? $signin_url : '@homepage'); 
    31     } 
    32     elseif ($user->isAuthenticated()) 
     30    if ($request->isMethod('post')) 
    3331    { 
    34       $this->redirect('@homepage'); 
     32      $this->form->bind($request->getParameter('signin')); 
     33      if ($this->form->isValid()) 
     34      { 
     35        $values = $this->form->getValues(); 
     36        $this->getUser()->signin($values['user']); 
     37 
     38        $signinUrl = sfConfig::get('app_sf_guard_plugin_success_signinUrl', $user->getReferer($request->getReferer())); 
     39 
     40        return $this->redirect('' != $signinUrl ? $signinUrl : '@homepage'); 
     41      } 
    3542    } 
    3643    else 
    3744    { 
    38       if ($this->getRequest()->isXmlHttpRequest()) 
     45      if ($request->isXmlHttpRequest()) 
    3946      { 
    4047        $this->getResponse()->setHeaderOnly(true); 
     
    4451      } 
    4552 
    46       if (!$user->hasAttribute('referer')) 
    47       { 
    48         $user->setAttribute('referer', $this->getRequest()->getReferer()); 
    49       } 
     53      $user->setReferer($request->getReferer()); 
    5054 
    51       if ($this->getModuleName() != ($module = sfConfig::get('sf_login_module'))) 
     55      $module = sfConfig::get('sf_login_module'); 
     56      if ($this->getModuleName() != $module) 
    5257      { 
    5358        return $this->redirect($module.'/'.sfConfig::get('sf_login_action')); 
     
    5863  } 
    5964 
    60   public function executeSignout(
     65  public function executeSignout($request
    6166  { 
    6267    $this->getUser()->signOut(); 
    6368 
    64     $signout_url = sfConfig::get('app_sf_guard_plugin_success_signout_url', $this->getRequest()->getReferer()); 
     69    $signout_url = sfConfig::get('app_sf_guard_plugin_success_signout_url', $request->getReferer()); 
    6570 
    6671    $this->redirect('' != $signout_url ? $signout_url : '@homepage'); 
     
    7681    throw new sfException('This method is not yet implemented.'); 
    7782  } 
    78  
    79   public function handleErrorSignin() 
    80   { 
    81     $user = $this->getUser(); 
    82     if (!$user->hasAttribute('referer')) 
    83     { 
    84       $user->setAttribute('referer', $this->getRequest()->getReferer()); 
    85     } 
    86  
    87     $module = sfConfig::get('sf_login_module'); 
    88     if ($this->getModuleName() != $module) 
    89     { 
    90       $this->forward(sfConfig::get('sf_login_module'), sfConfig::get('sf_login_action')); 
    91     } 
    92  
    93     return sfView::SUCCESS; 
    94   } 
    9583} 
  • plugins/sfGuardPlugin/branches/1.1/modules/sfGuardAuth/templates/secureSuccess.php

    r7634 r7745  
    11<?php use_helper('I18N') ?> 
    22 
    3 <p><?php echo __("You don't have the requested permission to access this page."); ?></p> 
     3<p><?php echo __("You don't have the requested permission to access this page.") ?></p> 
  • plugins/sfGuardPlugin/branches/1.1/modules/sfGuardAuth/templates/signinSuccess.php

    r7634 r7745  
    1 <?php use_helper('Validation', 'I18N') ?> 
     1<form action="<?php echo url_for('@sf_guard_signin') ?>" method="post" /> 
     2  <table> 
     3    <?php echo $form ?> 
     4  </table> 
    25 
    3 <div id="sf_guard_auth_form"> 
    4 <?php echo form_tag('@sf_guard_signin') ?> 
    5  
    6   <fieldset> 
    7  
    8     <div class="form-row" id="sf_guard_auth_username"> 
    9       <?php 
    10       echo form_error('username'),  
    11       label_for('username', __('username:')), 
    12       input_tag('username', $sf_data->get('sf_params')->get('username')); 
    13       ?> 
    14     </div> 
    15  
    16     <div class="form-row" id="sf_guard_auth_password"> 
    17       <?php 
    18       echo form_error('password'),  
    19         label_for('password', __('password:')), 
    20         input_password_tag('password'); 
    21       ?> 
    22     </div> 
    23     <div class="form-row" id="sf_guard_auth_remember"> 
    24       <?php 
    25       echo label_for('remember', __('Remember me?')), 
    26       checkbox_tag('remember'); 
    27       ?> 
    28     </div> 
    29   </fieldset> 
    30  
    31   <?php  
    32   echo submit_tag(__('sign in')),  
    33   link_to(__('Forgot your password?'), '@sf_guard_password', array('id' => 'sf_guard_auth_forgot_password'))  
    34   ?> 
     6  <input type="submit" value="sign in" /> 
     7  <a href="<?php echo url_for('@sf_guard_password') ?>">Forgot your password?</a> 
    358</form> 
    36 </div> 

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting.
Sensio Labs also supports several large Open-Source projects.