當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CPasswordHelper::hashPassword方法代碼示例

本文整理匯總了PHP中CPasswordHelper::hashPassword方法的典型用法代碼示例。如果您正苦於以下問題:PHP CPasswordHelper::hashPassword方法的具體用法?PHP CPasswordHelper::hashPassword怎麽用?PHP CPasswordHelper::hashPassword使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CPasswordHelper的用法示例。


在下文中一共展示了CPasswordHelper::hashPassword方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: createAdmin

 public function createAdmin()
 {
     $attributes = array('username' => 'admin', 'email' => 'test@mail.kom', 'password' => CPasswordHelper::hashPassword('iddqd3311'), 'email_verified' => 1);
     $user = new Users();
     $user->attributes = $attributes;
     $user->save();
 }
開發者ID:xunicorn,項目名稱:ebay-simple-watching,代碼行數:7,代碼來源:Users.php

示例2: beforeSave

 protected function beforeSave()
 {
     if (isset($this->senha)) {
         $this->senha = CPasswordHelper::hashPassword($this->senha);
     }
     return parent::beforeSave();
 }
開發者ID:jralison,項目名稱:chrono,代碼行數:7,代碼來源:Usuario.php

示例3: actionRegister

 public function actionRegister()
 {
     $username = $_POST['username'];
     $password = $_POST['password'];
     if (strlen($username) < 3) {
         Helper::renderJSONErorr("Username must be at least 3 symbols: {$username} [" . strlen($username) . "]");
     }
     if (strlen($password) < 5) {
         Helper::renderJSONErorr("Password must be at least 5 symbols");
     }
     // Check user
     $user = User::model()->find('username=:username', array(':username' => $username));
     if ($user) {
         Helper::renderJSONErorr("Username occupated");
     }
     // Create new user
     $model = new User();
     $model->username = $username;
     $model->password = CPasswordHelper::hashPassword($password);
     if ($model->save()) {
         Helper::renderJSON($model);
     }
     // Catch errors
     $errors = [];
     foreach ($model->errors as $attribute => $attr_errors) {
         foreach ($attr_errors as $attr_error) {
             $errors[] = "Attribute {$attribute}: {$attr_error}";
         }
     }
     Helper::renderJSONErorr(implode("\n", $errors));
 }
開發者ID:Alexnder,項目名稱:angular-yii-rest-test,代碼行數:31,代碼來源:UserController.php

示例4: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Propietario();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Propietario'])) {
         $model->attributes = $_POST['Propietario'];
         $usuario = new Usuario();
         $model->rut = Tools::removeDots($model->rut);
         $usuario->user = $model->rut;
         $arr = explode("-", $model->rut);
         $usuario->clave = CPasswordHelper::hashPassword($arr[0]);
         $usuario->rol = "propietario";
         $usuario->nombre = $_POST['Propietario']['nombre'];
         $usuario->email = $_POST['Propietario']['email'];
         $usuario->apellido = $_POST['Propietario']['apellido'];
         $model->usuario_id = 1;
         if ($model->validate()) {
             if ($usuario->validate()) {
                 if ($usuario->save()) {
                     $model->usuario_id = $usuario->id;
                     if ($model->save()) {
                         $auth = Yii::app()->authManager;
                         Authassignment::model()->deleteAllByAttributes(array('userid' => $usuario->id));
                         $auth->revoke($usuario->rol, $model->usuario_id);
                         $auth->assign($usuario->rol, $model->usuario_id);
                         $this->redirect(array('view', 'id' => $model->id));
                     }
                 }
             }
         }
     }
     $this->render('create', array('model' => $model));
 }
開發者ID:crmoya,項目名稱:inmobiliaria,代碼行數:38,代碼來源:PropietarioController.php

示例5: __set

 public function __set($name, $value)
 {
     if ($name === 'password') {
         $value = CPasswordHelper::hashPassword($value);
     }
     parent::__set($name, $value);
     // TODO: Change the autogenerated stub
 }
開發者ID:yakleg,項目名稱:gosbroker,代碼行數:8,代碼來源:User.php

示例6: hashPassword

 /**
  *
  * 某些係統不支持crypt加密。隻能用md5加密了
  *
  *
  * @param password        客戶端傳遞過來的密碼
  *@param array $params
  * @return string
  */
 public function hashPassword($password, array $params = array())
 {
     if (!function_exists('crypt')) {
         return CPasswordHelper::hashPassword($password);
     } else {
         return md5($password);
     }
 }
開發者ID:tiger2soft,項目名稱:travelman,代碼行數:17,代碼來源:Hasher.php

示例7: changePassword

 public function changePassword()
 {
     $user = Yii::app()->controller->user;
     $user->password = CPasswordHelper::hashPassword($this->newPassword);
     if ($user->save()) {
         return true;
     } else {
         return false;
     }
 }
開發者ID:sunshy360,項目名稱:cubingchina,代碼行數:10,代碼來源:ChangePasswordForm.php

示例8: hashPassword

 /**
  * Hashes a given password with the blowfish encryption algorithm.
  *
  * @param string $string       The string to hash
  * @param bool   $validateHash If you want to validate the just generated hash. Will throw an exception if
  *                             validation fails.
  *
  * @throws Exception
  * @return string The hash.
  */
 public function hashPassword($string, $validateHash = false)
 {
     $hash = \CPasswordHelper::hashPassword($string, $this->_blowFishHashCost);
     if ($validateHash) {
         if (!$this->checkPassword($string, $hash)) {
             throw new Exception(Craft::t('Could not hash the given string.'));
         }
     }
     return $hash;
 }
開發者ID:kentonquatman,項目名稱:portfolio,代碼行數:20,代碼來源:SecurityService.php

示例9: beforeSave

 /**
  * Este método se llama cuando inserto o edito un registro.
  */
 public function beforeSave()
 {
     if (parent::beforeSave()) {
         if (!empty($this->newPassword) && $this->newPassword == $this->rePassword) {
             $this->password = CPasswordHelper::hashPassword($this->newPassword);
         }
         return true;
     }
     return false;
 }
開發者ID:Lucerin,項目名稱:Yii-projects,代碼行數:13,代碼來源:Users.php

示例10: save

 /**
  * Updates the users password.
  * @param bool $runValidation
  */
 public function save($runValidation = true)
 {
     if ($runValidation && !$this->validate()) {
         return false;
     }
     /** @var AccountModule $account */
     $account = Yii::app()->getModule('account');
     $this->user->{$account->passwordField} = CPasswordHelper::hashPassword($this->new_password);
     return $this->user->save(false);
 }
開發者ID:cornernote,項目名稱:yii-account-module,代碼行數:14,代碼來源:AccountChangePassword.php

示例11: beforeSave

 public function beforeSave()
 {
     if ($this->isNewRecord) {
         $this->created = new CDbExpression('NOW()');
     }
     $this->updated = new CDbExpression('NOW()');
     if ($this->pass != '') {
         $this->password = CPasswordHelper::hashPassword($this->pass);
     }
     return parent::beforeSave();
 }
開發者ID:anton-itscript,項目名稱:WM-Web,代碼行數:11,代碼來源:User.php

示例12: beforeSave

 /**
  * Password hashing
  * @return bool
  */
 protected function beforeSave()
 {
     if (parent::beforeSave()) {
         if ($this->isNewRecord) {
             $this->password = CPasswordHelper::hashPassword($this->password);
         }
         return true;
     } else {
         return false;
     }
 }
開發者ID:AlexanderKupriyanov,項目名稱:test-yii,代碼行數:15,代碼來源:User.php

示例13: save

 /**
  * Updates the users password.
  * @param bool $runValidation
  */
 public function save($runValidation = true)
 {
     if ($runValidation && !$this->validate()) {
         return false;
     }
     /** @var AccountModule $account */
     $account = Yii::app()->getModule('account');
     //to avoid indirect modification error message
     $user = $this->user;
     $user->{$account->passwordField} = CPasswordHelper::hashPassword($this->new_password);
     return $user->save(false);
 }
開發者ID:zainengineer,項目名稱:yii-account-module,代碼行數:16,代碼來源:AccountChangePassword.php

示例14: actionRegister

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionRegister()
 {
     $model = new User();
     $this->performAjaxValidation($model);
     if (isset($_POST['User'])) {
         $model->attributes = $_POST['User'];
         $model->password = CPasswordHelper::hashPassword($model->password);
         if ($model->save()) {
             $this->redirect(array('site/login'));
         }
     }
     $this->render('register', array('model' => $model));
 }
開發者ID:nsdvw,項目名稱:classifieds,代碼行數:17,代碼來源:UserController.php

示例15: beforeSave

 protected function beforeSave()
 {
     $this->username = trim(strtolower($this->username));
     if ($this->password === '') {
         $model2 = User::model()->findByPk($this->id);
         $this->password = $model2->password;
         $this->repeatPassword = $model2->password;
     } elseif ($this->repeatPassword !== null) {
         $this->unecryptedPassword = $this->password;
         $this->password = CPasswordHelper::hashPassword($this->password);
         $this->repeatPassword = CPasswordHelper::hashPassword($this->repeatPassword);
     }
     return true;
 }
開發者ID:ho96,項目名稱:yii-admin,代碼行數:14,代碼來源:User.php


注:本文中的CPasswordHelper::hashPassword方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。