當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。