ここの情報は古いです。ご理解頂いた上でお取り扱いください。

Changeset 9955


Ignore:
Timestamp:
Jan 6, 2009, 7:20:49 PM (11 years ago)
Author:
ebihara
Message:

#3214:added ability to change an admin user password

Location:
OpenPNE3/trunk
Files:
3 added
5 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE3/trunk/apps/pc_backend/lib/opAdminLoginForm.class.php

    r9954 r9955  
    3636  }
    3737
    38   public function validate($validator, $values, $arguments = array())
     38  public static function validate($validator, $values, $arguments = array())
    3939  {
    40     $admin_user = AdminUserPeer::retrieveByUsername($values['username']);
    41     if (!$admin_user) {
    42       return false;
     40    $adminUser = AdminUserPeer::retrieveByUsername($values['username']);
     41    if (!$adminUser)
     42    {
     43      throw new sfValidatorError($validator, 'invalid');
    4344    }
    4445
    45     return $admin_user->getPassword() === md5($values['password']);
     46    if ($adminUser->getPassword() === md5($values['password']))
     47    {
     48      $values['adminUser'] = $adminUser;
     49      return $values;
     50    }
     51
     52    throw new sfValidatorError($validator, 'invalid');
    4653  }
    4754}
  • OpenPNE3/trunk/apps/pc_backend/modules/admin/actions/actions.class.php

    r9954 r9955  
    4444    }
    4545  }
     46
     47 /**
     48  * Executes editPassword action
     49  *
     50  * @param sfRequest $request A request object
     51  */
     52  public function executeEditPassword(sfWebRequest $request)
     53  {
     54    $user = AdminUserPeer::retrieveByPk($this->getUser()->getAttribute('adminUserId', null, 'adminUser'));
     55    $this->form = new AdminUserEditPasswordForm($user);
     56    if ($request->isMethod(sfWebRequest::POST))
     57    {
     58      $params = $request->getParameter('admin_user');
     59      $this->redirectIf($this->form->bindAndSave($params), 'admin/manageUser');
     60    }
     61  }
    4662}
  • OpenPNE3/trunk/apps/pc_backend/modules/admin/templates/_submenu.php

    r9954 r9955  
    11<li><?php echo link_to(__('アカウント管理'), 'admin/manageUser') ?></li>
     2<li><?php echo link_to(__('パスワード変更'), 'admin/editPassword') ?></li>
  • OpenPNE3/trunk/apps/pc_backend/modules/default/actions/loginAction.class.php

    r9954 r9955  
    2727      {
    2828        $this->getUser()->setAuthenticated(true);
     29        $this->getUser()->setAttribute('adminUserId', $this->form->getValue('adminUser')->getId(), 'adminUser');
    2930        $this->redirect('default/top');
    3031      }
  • OpenPNE3/trunk/lib/model/AdminUser.php

    r7902 r9955  
    1010class AdminUser extends BaseAdminUser
    1111{
     12  public function doSave($con = null)
     13  {
     14    $this->setPassword(md5($this->getPassword()));
     15    return parent::doSave($con);
     16  }
    1217}
Note: See TracChangeset for help on using the changeset viewer.