本文整理汇总了PHP中app\models\Users::setPassword方法的典型用法代码示例。如果您正苦于以下问题:PHP Users::setPassword方法的具体用法?PHP Users::setPassword怎么用?PHP Users::setPassword使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Users
的用法示例。
在下文中一共展示了Users::setPassword方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreate
/**
* Creates a new Users model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Users();
$model->setScenario('register');
$post = Yii::$app->request->post();
$formName = basename($model->className());
if ($model->load($post)) {
// Default value
$model->is_super_admin = isset($post[$formName]['is_super_admin']) ? $post[$formName]['is_super_admin'] : 0;
$model->role = $model->is_super_admin ? Identity::ROLE_SUPERADMIN : 30;
$model->fecha_conexion = isset($post[$formName]['fecha_conexion']) ? $post[$formName]['fecha_conexion'] : Yii::$app->fn->GetDate('none');
$model->fecha_modif = isset($post[$formName]['fecha_modif']) ? $post[$formName]['fecha_modif'] : Yii::$app->fn->GetDate('none');
$model->fecha_registro = isset($post[$formName]['fecha_registro']) ? $post[$formName]['fecha_registro'] : Yii::$app->fn->GetDate();
$model->id_estado = isset($post[$formName]['id_estado']) ? $post[$formName]['id_estado'] : 1;
if ($model->validate()) {
$model->setPassword();
$model->generateAuthKey();
if ($model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
}
}
}
// Load empty/error form
return $this->render('create', ['model' => $model]);
}
示例2: registerAction
public function registerAction()
{
try {
$form = new \RegisterForm();
if ($this->request->isPost()) {
$email = $this->request->getPost('email', 'email');
$password = $this->request->getPost('password');
$repeatPassword = $this->request->getPost('repeatPassword');
$user = new Users();
$user->setPassword($password, $repeatPassword);
$user->email = $email;
$user->created_at = new \Phalcon\Db\RawValue('now()');
$user->user_name = $this->request->getPost('name', ['string', 'striptags']);
$user->nickname = $this->request->getPost('nickname', 'string');
if ($user->save() == false) {
foreach ($user->getMessages() as $message) {
$this->flash->error((string) $message);
}
} else {
$this->tag->setDefault('email', '');
$this->tag->setDefault('password', '');
$this->auth->login($user->toArray());
$user->sendEmailAfterReg();
return $this->goToMain();
}
}
} catch (\Exception $e) {
$this->flash->error($e->getMessage());
}
$this->view->form = $form;
}
示例3: reg
public function reg()
{
$user = new Users();
$user->username = $this->username;
$user->setPassword($this->password);
$user->generateAuthKey();
$user->save();
return $user;
}
示例4: beforeSave
public function beforeSave($insert)
{
if (parent::beforeSave($insert)) {
$adminUserModel = new Users();
$adminUserModel->setPassword($this->password_hash);
//print_r($adminUserModel->password_hash);exit();
$this->password_hash = $adminUserModel->password_hash;
return true;
} else {
return false;
}
}
示例5: signup
public function signup()
{
if ($this->validate()) {
$users = new Users();
$users->name = $this->name;
$users->email = $this->email;
$users->status = $this->status;
$users->setPassword($this->password);
$users->generateAuthKey();
return $users->save() ? $users : null;
}
return null;
}
示例6: reg
public function reg()
{
$user = new Users();
$user->family = $this->family;
$user->name = $this->name;
$user->father = $this->father;
$user->login = $this->login;
$user->setPassword($this->password);
$user->email = $this->email;
$user->phone = $this->phone;
//$user->generateAuthKey();
return $user->save() ? $user : null;
}