当前位置: 首页>>代码示例>>PHP>>正文


PHP AuthComponent::password方法代码示例

本文整理汇总了PHP中AuthComponent::password方法的典型用法代码示例。如果您正苦于以下问题:PHP AuthComponent::password方法的具体用法?PHP AuthComponent::password怎么用?PHP AuthComponent::password使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AuthComponent的用法示例。


在下文中一共展示了AuthComponent::password方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: beforeSave

 public function beforeSave($options = array())
 {
     /* password hashing */
     if (isset($this->data[$this->alias]['password'])) {
         $this->data[$this->alias]['password'] = AuthComponent::password($this->data[$this->alias]['password']);
     }
 }
开发者ID:prabhavsharma,项目名称:Music-Online,代码行数:7,代码来源:User.php

示例2: install

 public function install()
 {
     //TODO check if tables are present in db. If not, trigger schema create --plugin Backend
     // setup default backend user groups
     $groups = array('superuser' => array('name' => 'Superuser', 'root' => true), 'admin' => array('name' => 'Administrator', 'root' => false));
     $BackendUserGroup = ClassRegistry::init('Backend.BackendUserGroup');
     foreach ($groups as &$group) {
         $BackendUserGroup->create();
         if (!$BackendUserGroup->save(array('BackendUserGroup' => $group))) {
             $this->out('<warning>Failed to create Backend User Group ' . $group['name'] . '</warning>');
         } else {
             $this->out('<success>Created Backend User Group ' . $group['name'] . '</success>');
         }
     }
     // setup superuser
     $superGroup = $BackendUserGroup->find('first', array('conditions' => array('BackendUserGroup.root' => true)));
     if (!$superGroup) {
         $this->error('No root BackendUserGroup found');
     }
     $email = $this->in('Superuser email:', '', 'flohax@yahoo.de');
     $superuser = array('backend_user_group_id' => $superGroup['BackendUserGroup']['id'], 'username' => 'superuser', 'password' => AuthComponent::password('superPass'), 'first_name' => 'John', 'last_name' => 'Doe', 'mail' => $email, 'published' => true);
     $BackendUser = ClassRegistry::init('Backend.BackendUser');
     if (!$BackendUser->save(array('BackendUser' => $superuser), true)) {
         $this->out('<warning>Failed to create Backend Superuser</warning>');
     } else {
         $this->out('<success>Superuser created (Password: superPass)</success>');
     }
 }
开发者ID:fm-labs,项目名称:cakephp-backend,代码行数:28,代码来源:BackendShell.php

示例3: beforeSave

 public function beforeSave($options = array())
 {
     //when password field
     if (isset($this->data[$this->alias]['password']) && isset($this->data[$this->alias]['password2'])) {
         if (empty($this->data[$this->alias]['password']) && empty($this->data[$this->alias]['password2'])) {
             unset($this->data[$this->alias]['password']);
             unset($this->data[$this->alias]['password2']);
         } elseif (!empty($this->data[$this->alias]['password'])) {
             if ($this->data[$this->alias]['password'] != $this->data[$this->alias]['password2']) {
                 $this->invalidate('password', __d('backend', "The passwords do not match"));
                 $this->invalidate('password2', __d('backend', "The passwords do not match"));
                 $this->data[$this->alias]['password2'] = null;
                 return false;
             }
         }
     } elseif (isset($this->data[$this->alias]['password'])) {
         $this->invalidate('password', __d('backend', 'Password verification not submitted'));
         $this->invalidate('password2', __d('backend', 'Password verification not submitted'));
         return false;
     }
     if (isset($this->data[$this->alias]['password']) && !empty($this->data[$this->alias]['password'])) {
         $this->data[$this->alias]['password'] = AuthComponent::password($this->data[$this->alias]['password']);
     }
     return true;
 }
开发者ID:fm-labs,项目名称:cakephp-backend,代码行数:25,代码来源:BackendUser.php

示例4: index

 public function index()
 {
     if ($this->Auth->user('id')) {
         $user = $this->User->findById($this->Auth->user());
         $this->set('user', $user);
         if ($this->request->is('post')) {
             $req = $this->request->data;
             if ($user['User']['password'] == AuthComponent::password($req['User']['old_password'])) {
                 if ($req['User']['password'] == $req['User']['password_verify']) {
                     $user['User']['password'] = $req['User']['password'];
                     if ($this->User->save($user)) {
                         $this->Session->setFlash('New Password Saved!');
                     } else {
                         $this->Session->setFlash('The new passwords didn\'t match.');
                     }
                 } else {
                     $this->Session->setFlash('The new passwords didn\'t match.');
                 }
             } else {
                 $this->Session->setFlash('The old password you entered was incorrect');
             }
         }
     } else {
         $this->redirect('/login');
     }
 }
开发者ID:rsmartin,项目名称:NiceAuth,代码行数:26,代码来源:UsersController.php

示例5: save_user

 function save_user($data = null)
 {
     $user_id = "";
     if (isset($data['User']['parent_id']) && $data['User']['parent_id'] == "") {
         $data['User']['parent_id'] = 0;
     }
     if (isset($data['User']['is_dealer']) && $data['User']['is_dealer'] == "") {
         $data['User']['is_dealer'] = 0;
     }
     if (isset($data['User']['role_id']) && $data['User']['role_id'] == 2) {
         //|| ($data['User']['role_id'] == 3)
     } else {
         unset($data['User']['selling_price_limit']);
     }
     if (!empty($data['User']['powd'])) {
         $data['User']['powd'] = AuthComponent::password(AuthComponent::password($data['User']['powd']));
     }
     if (isset($data['User']['id']) && trim($data['User']['powd'] == "")) {
         unset($data['User']['powd']);
     }
     if ($this->saveAll($data)) {
         if (isset($data['User']['id']) && !empty($data['User']['id'])) {
             $user_id = $data['User']['id'];
         } else {
             $user_id = $this->getLastInsertId();
         }
     }
     return $user_id;
 }
开发者ID:89itworld,项目名称:hallo,代码行数:29,代码来源:User.php

示例6: beforeSave

 public function beforeSave($options = array())
 {
     parent::beforeSave($options);
     if (isset($this->data['User']['password'])) {
         $this->data['User']['password'] = AuthComponent::password($this->data['User']['password']);
     }
 }
开发者ID:jeraldluyas,项目名称:chatsystem2,代码行数:7,代码来源:User.php

示例7: beforeSave

 public function beforeSave($options = array())
 {
     if (!empty($this->data['User']['image'])) {
         if ($this->data['User']['image']['size'] != 0) {
             $fileData = $this->resizeImage(512, $this->data['User']['image']['tmp_name']);
             if (!isset($fileData)) {
                 $fileData = fread(fopen($this->data['User']['image']['tmp_name'], 'r'), $this->data['User']['image']['size']);
             }
             //            debug($fileData);
             //            throw new Exception;
             $this->data['User']['image_type'] = $this->data['User']['image']['type'];
             $this->data['User']['image'] = $fileData;
         } else {
             $this->data['User']['image'] = null;
             $this->data['User']['image_extension'] = null;
         }
     }
     //App::import('Component','Auth');
     //$AuthComponent = new AuthComponent(new ComponentCollection);
     //AuthComponent->password($this->data['User']['password'])
     if (isset($this->data[$this->alias]['password']) && strlen(trim($this->data[$this->alias]['password'])) != 0) {
         $this->data[$this->alias]['password'] = AuthComponent::password($this->data['User']['password']);
     } else {
         unset($this->data['User']['password']);
     }
     return true;
 }
开发者ID:sing-group,项目名称:Markyt,代码行数:27,代码来源:User.php

示例8: beforeSave

 /**
  * Hash passwords
  * @see Model::beforeSave()
  */
 public function beforeSave($options = array())
 {
     if (!empty($this->data[$this->alias]['password'])) {
         $this->data[$this->alias]['password'] = AuthComponent::password($this->data[$this->alias]['password']);
     }
     return TRUE;
 }
开发者ID:rawroland,项目名称:Cars-Test,代码行数:11,代码来源:User.php

示例9: change_password

 public function change_password($id = null)
 {
     $this->set('subid', 'change_pass');
     $this->set('titulo', 'Usuários');
     $this->set('subtitulo', '');
     $this->loadModel('Group');
     $erros = array();
     if ($this->request->is('post')) {
         $currentpass = $this->Auth->password($this->request->data['User']['current_password']);
         $exists = $this->User->findByUsernameAndPassword($this->Auth->user('username'), $currentpass);
         if (!$exists) {
             $this->Session->setFlash('Senha Errada', 'flash_custom', array('type' => 'error'));
             return;
         }
         $pass = $this->request->data['User']['password'];
         if ($pass != $this->request->data['User']['password_confirm']) {
             $this->Session->setFlash('A senha e a confirmação precisam ser iguais', 'flash_custom', array('type' => 'error'));
             return;
         }
         $novocurso = array('password' => $this->Auth->password($pass));
         $this->User->id = $this->Auth->user('id');
         if ($this->User->save($novocurso, false) && !count($erros)) {
             $this->Session->setFlash('Senha trocada com sucesso', 'flash_custom', array('type' => 'success'));
             $this->redirect(array('controller' => 'Users', 'action' => 'index'));
         } else {
             $erros = array_merge($erros, $this->User->validationErrors);
             $this->set('user', $novocurso);
         }
     }
     if (count($erros)) {
         $this->Session->setFlash('O formulário contém erros', 'flash_custom', array('type' => 'error'));
     }
     $this->set('erros', $erros);
 }
开发者ID:michelmfreitas,项目名称:iPixels-Restaurante,代码行数:34,代码来源:UsersController.php

示例10: beforeSave

 public function beforeSave($options = array())
 {
     if (isset($this->data['CloggyUser']['user_password']) && !empty($this->data['CloggyUser']['user_password'])) {
         $this->data['CloggyUser']['user_password'] = AuthComponent::password($this->data['CloggyUser']['user_password']);
     }
     return true;
 }
开发者ID:simaostephanie,项目名称:Cloggy,代码行数:7,代码来源:CloggyUser.php

示例11: recover

 public function recover()
 {
     $this->autoRender = false;
     $email = $this->param('email');
     $this->loadModel('User');
     $usr = $this->User->findByEmail($email);
     if ($usr) {
         $this->User->create();
         $this->User->id = $usr['User']['id'];
         $mail = $this->PHPMailer->getPHPMailer();
         $nova = $this->randomPassword();
         $this->User->saveField('password', AuthComponent::password($nova));
         $mail->AddAddress($email);
         $mail->SetFrom('website@marialembrancinha.com.br', 'Website');
         $mail->Subject = utf8_decode("Recuperação de Senha");
         $mail->MsgHTML("Sua nova senha: {$nova}");
         $sent = $mail->Send();
         if (!$sent) {
             echo json_encode(new Message(0, 'E-mail nao pode ser enviado'));
             return;
         }
         echo json_encode(new Message(1, 'Nova senha enviada para seu email'));
         return;
     }
     echo json_encode(new Message(0, 'Erro ao recuperar sua senha'));
     return;
 }
开发者ID:michelmfreitas,项目名称:iPixels-Restaurante,代码行数:27,代码来源:AutenticacaoController.php

示例12: beforeSave

 public function beforeSave($options = array())
 {
     if (isset($this->data[$this->alias]['password'])) {
         $this->data[$this->alias]['password'] = AuthComponent::password($this->data[$this->alias]['password']);
     }
     return true;
 }
开发者ID:elaleprieto,项目名称:vbiblio,代码行数:7,代码来源:User.php

示例13: change_password

 public function change_password()
 {
     if ($this->request->is('post')) {
         $old_pass = AuthComponent::password($this->data['Admin']['old_password']);
         $check_exist = $this->Admin->findByPassword($old_pass);
         if ($check_exist) {
             $update_new_pass = array();
             $update_new_pass['Admin']['id'] = $this->activeUser['User']['id'];
             $update_new_pass['Admin']['password'] = $this->data['Admin']['new_password'];
             if ($this->Admin->save($update_new_pass)) {
                 // Display success message and redirect
                 $this->Session->setFlash('Password changed successfully.', 'default', array('class' => 'alert alert-success'), 'success');
                 $this->redirect(array('controller' => 'home', 'action' => 'index'));
             } else {
                 // Display failure message and redirect
                 $this->Session->setFlash('Sorry, an error occurred.', 'default', array('class' => 'alert alert-danger'), 'error');
                 $this->redirect(array('controller' => 'admins', 'action' => 'change_password'));
             }
         } else {
             // Display failure message and redirect
             $this->Session->setFlash('Invalid current password.', 'default', array('class' => 'alert alert-danger'), 'error');
             $this->redirect(array('controller' => 'admins', 'action' => 'change_password'));
         }
     }
     // Set the view variables to controller variable values and layout for the view
     $this->set('page_title', 'Change Password');
     $this->layout = "base_layout";
 }
开发者ID:riddhisoni1324,项目名称:cakephp_fxchng,代码行数:28,代码来源:AdminsController.php

示例14: beforeSave

 /**
  * beforeSave callback
  * Check if user name is unique and allowed in aro
  * Encrypt password
  *
  * @param array model options
  * @access public
  * @return boolean
  */
 public function beforeSave($options = array())
 {
     App::uses('Aro', 'Model');
     $this->Aro = new Aro();
     // alias = user name ,  must be unique
     $this->Aro->validate = array('alias' => array('rule' => 'isUnique', 'message' => __('This name is restricted by system.')));
     $aro = $this->Aro->findByForeignKey($this->id);
     if ($aro) {
         $aro['Aro']['alias'] = $this->data['User']['name'];
         $aro = $aro['Aro'];
         $this->Aro->set($aro);
     }
     if ($aro && !$this->Aro->validates($aro)) {
         $errors = $this->Aro->validationErrors;
         $this->data = null;
         return false;
     }
     // crypt and truncate password
     if (isset($this->data[$this->alias]['password'])) {
         $this->data[$this->alias]['password'] = AuthComponent::password(substr($this->data[$this->alias]['password'], 0, 8));
     }
     // truncate username
     if (isset($this->data[$this->alias]['username'])) {
         $this->data[$this->alias]['username'] = substr($this->data[$this->alias]['username'], 0, 8);
     }
     return true;
 }
开发者ID:jefflv,项目名称:phkapa,代码行数:36,代码来源:User.php

示例15: beforeSave

 /**
  * Cada vez que um um usuario for salvo, faz hash da senha dele, que sera
  * gravada no banco
  * @return boolean 
  */
 public function beforeSave()
 {
     if (isset($this->data[$this->alias]['senha'])) {
         $this->data[$this->alias]['senha'] = AuthComponent::password($this->data[$this->alias]['senha']);
     }
     return true;
 }
开发者ID:renanmpimentel,项目名称:liber,代码行数:12,代码来源:Usuario.php


注:本文中的AuthComponent::password方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。