本文整理汇总了PHP中CPasswordHelper类的典型用法代码示例。如果您正苦于以下问题:PHP CPasswordHelper类的具体用法?PHP CPasswordHelper怎么用?PHP CPasswordHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CPasswordHelper类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: authenticate
/**
* Authentication
* @return bool
*/
public function authenticate()
{
/** @var AccountModule $account */
$account = Yii::app()->getModule('account');
/** @var AccountUser $user */
$user = CActiveRecord::model($account->userClass)->find('(LOWER(username)=? OR LOWER(email)=?)', array(strtolower($this->username), strtolower($this->username)));
if (!$user) {
$this->errorCode = self::ERROR_USERNAME_INVALID;
return false;
}
if ($account->activatedField && !$user->{$account->activatedField}) {
$this->errorCode = self::ERROR_NOT_ACTIVATED;
return false;
}
if ($account->disabledField && $user->{$account->disabledField}) {
$this->errorCode = self::ERROR_DISABLED;
return false;
}
if (!$this->skipPassword && !CPasswordHelper::verifyPassword($this->password, $user->{$account->passwordField})) {
$this->errorCode = self::ERROR_PASSWORD_INVALID;
return false;
}
$this->_id = $user->primaryKey;
$this->username = $account->usernameField && $user->{$account->usernameField} ? $user->{$account->usernameField} : $user->{$account->emailField};
$this->errorCode = self::ERROR_NONE;
return true;
}
开发者ID:cornernote,项目名称:yii-account-module,代码行数:31,代码来源:AccountUserIdentity.php
示例2: validatePassword
public function validatePassword($user)
{
if ($user->password) {
return CPasswordHelper::verifyPassword($this->password, $user->password);
}
return true;
}
开发者ID:KEMSolutions,项目名称:Boukem1,代码行数:7,代码来源:UserIdentity.php
示例3: authenticate
/**
* Overrides the parent method.
*
* @return integer Returns the error code.
*/
public function authenticate()
{
$this->errorCode = self::ERROR_NONE;
if (isset($this->username) && isset($this->password)) {
$this->user = User::model()->findByAttributes(array('email' => $this->username));
if (isset($this->user)) {
if ($this->user->status == User::STATUS_ACTIVE) {
if (CPasswordHelper::verifyPassword($this->password, $this->user->password)) {
Yii::app()->user->login($this);
//TODO: write a log here
} else {
$this->errorCode = self::ERROR_PASSWORD_INVALID;
//TODO: write a log here
}
} else {
$this->errorCode = self::ERROR_USERNAME_INACTIVE;
//TODO: write a log here
}
} else {
$this->errorCode = self::ERROR_USERNAME_INVALID;
//TODO: write a log here
}
}
return $this->errorCode;
}
开发者ID:bafio89,项目名称:qea-u,代码行数:30,代码来源:BasicUserIdentity.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: beforeSave
protected function beforeSave()
{
if (isset($this->senha)) {
$this->senha = CPasswordHelper::hashPassword($this->senha);
}
return parent::beforeSave();
}
开发者ID:jralison,项目名称:chrono,代码行数:7,代码来源:Usuario.php
示例6: authenticate
public function authenticate()
{
$record = User::model()->findByAttributes(array('username' => $this->username));
if ($record === null) {
$this->errorCode = self::ERROR_USERNAME_INVALID;
} else {
if (!CPasswordHelper::verifyPassword($this->password, $record->password)) {
$this->errorCode = self::ERROR_PASSWORD_INVALID;
} else {
$access = AccessGlobal::getAction($record->role == 'superadmin' ? '0' : '1');
if ($record->role == 'user') {
$access['site'] = array_intersect($access['site'], AccessGlobal::getActionFromArrayId(AccessUser::getActionIdFromUser($record->user_id)));
}
if ($record->role == 'admin') {
$access['site'] = array_intersect($access['site'], AccessGlobal::getActionFromArrayId(AccessUser::getActionIdFromUser($record->user_id)));
}
$this->_id = $record->user_id;
$this->setState('role', $record->role);
$this->setState('name', $this->username);
$this->setState('access', $access);
$this->errorCode = self::ERROR_NONE;
}
}
return !$this->errorCode;
}
开发者ID:anton-itscript,项目名称:WM,代码行数:25,代码来源:UserIdentity.php
示例7: createAdmin
public function createAdmin()
{
$attributes = array('username' => 'admin', 'email' => '[email protected]', 'password' => CPasswordHelper::hashPassword('iddqd3311'), 'email_verified' => 1);
$user = new Users();
$user->attributes = $attributes;
$user->save();
}
开发者ID:xunicorn,项目名称:ebay-simple-watching,代码行数:7,代码来源:Users.php
示例8: authenticate
public function authenticate()
{
$user = User::model()->with('service')->find('username=:u', ['u' => $this->username]);
$verifyPassword = false;
if (empty($user)) {
$state = 1;
} else {
$verifyPassword = CPasswordHelper::verifyPassword($this->password, $user->password);
$state = $verifyPassword ? 0 : 1;
}
$result = Fraudmetrix::login($this->username, $state);
if ($result['success'] == true && $result['final_decision'] == 'Reject') {
$this->errorCode = self::ERROR_UNKNOWN_IDENTITY;
$this->errorMessage = '未知错误';
} else {
if (empty($user)) {
$this->errorCode = self::ERROR_USERNAME_INVALID;
$this->errorMessage = '用户邮箱不存在';
} else {
if ($user->state == 1) {
$this->errorCode = self::ERROR_NOT_LOGIN;
$this->errorMessage = '登录账号已被锁定';
} elseif (!$verifyPassword) {
$this->errorCode = self::ERROR_PASSWORD_INVALID;
$this->errorMessage = '用户密码错误';
} else {
$server = Setting::model()->get('wakfu', 'server');
$this->errorCode = self::ERROR_NONE;
$this->setPersistentStates(array_merge($user->getAttributes(), ['last_login_time' => $user->last_login_time, 'last_login_ip' => $user->last_login_ip, 'sign_up_time' => $user->sign_up_time, 'sign_up_ip' => $user->sign_up_ip, 'server' => $server[$user->service->server], 'port' => $user->service->port]));
$this->afterLogin($user);
}
}
}
return !$this->errorCode;
}
开发者ID:syxoasis,项目名称:wakfu-sae,代码行数:35,代码来源:UserIdentity.php
示例9: checkOldPassword
/**
*
* @param unknown $attribute
* @param unknown $params
*/
public function checkOldPassword($attribute, $params)
{
$user = User::model()->findByAttributes(array('id' => Yii::app()->user->getId()));
if (!empty($this->oldPassword) && !CPasswordHelper::verifyPassword($this->oldPassword, $user->password)) {
$this->addError('oldPassword', Yii::t('ProfileModule.password', 'error.password.oldPasswordWrong'));
}
}
开发者ID:bafio89,项目名称:qea-u,代码行数:12,代码来源:ChangePasswordForm.php
示例10: 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
示例11: authenticate
/**
* Authenticates the password.
* This is the 'authenticate' validator as declared in rules().
*/
public function authenticate($attribute, $params)
{
if (!$this->hasErrors()) {
if (!CPasswordHelper::verifyPassword($this->old_password, Yii::app()->user->user->password)) {
$this->addError('old_password', Yii::t("app", "Le mot de passe actuel entré est incorrect."));
}
}
}
开发者ID:KEMSolutions,项目名称:Boukem1,代码行数:12,代码来源:UpdatePasswordForm.php
示例12: __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
示例13: 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
示例14: 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
示例15: compareOldPassword
public function compareOldPassword($attribute)
{
//return($old->password === Yii::app()->digester->md5($_password));
$userlogin = User::model()->findByPk($this->id);
if (CPasswordHelper::verifyPassword($this->{$attribute}, $userlogin->password)) {
return TRUE;
} else {
$this->addError('oldpassword', 'Password Lama yang anda masukkan salah');
}
}
开发者ID:jordan095,项目名称:kpu-iadel,代码行数:10,代码来源:UpdatePasswordForm2.php
示例16: 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
示例17: 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
示例18: authenticate
public function authenticate()
{
$user = User::model()->findByAttributes(array('email' => $this->username, 'status' => array(User::STATUS_NORMAL, User::STATUS_BANNED)));
if ($user === null || CPasswordHelper::verifyPassword($this->password, $user->password) === false) {
$this->errorCode = self::ERROR_PASSWORD_INVALID;
} else {
$this->id = $user->id;
$this->errorCode = self::ERROR_NONE;
}
return !$this->errorCode;
}
开发者ID:sunshy360,项目名称:cubingchina,代码行数:11,代码来源:UserIdentity.php
示例19: 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
示例20: 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
注:本文中的CPasswordHelper类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论