当前位置: 首页>>代码示例>>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;未经允许,请勿转载。