本文整理汇总了PHP中backend\models\User::generateAuthKey方法的典型用法代码示例。如果您正苦于以下问题:PHP User::generateAuthKey方法的具体用法?PHP User::generateAuthKey怎么用?PHP User::generateAuthKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类backend\models\User
的用法示例。
在下文中一共展示了User::generateAuthKey方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: reg
public function reg()
{
$user = new User();
$user->username = $this->username;
$user->email = $this->email;
$user->status = $this->status;
$user->setPassword($this->password);
$user->generateAuthKey();
return $user->save() ? $user : null;
}
示例2: actionCreate
/**
* 创建用户
*
* @return mixed
*/
public function actionCreate()
{
$model = new User();
if ($model->load(Yii::$app->request->post())) {
$model->setPassword('123456');
$model->generateAuthKey();
//$model->signup();
$ret = $model->save();
if ($ret) {
return $this->redirect(['index']);
}
}
return $this->render('create', ['model' => $model]);
}
示例3: signup
/**
* Signs user up.
*
* @return User|null the saved model or null if saving fails
*/
public function signup()
{
if ($this->validate()) {
$user = new User();
$user->username = $this->username;
$user->email = $this->email;
$user->setPassword($this->password);
$user->generateAuthKey();
if ($user->save()) {
return $user;
}
}
return null;
}
示例4: create
/**
* function ::create ($data)
*/
public static function create($data)
{
$now = strtotime('now');
$username = Yii::$app->user->identity->username;
$model = new User();
if ($model->load($data)) {
if ($log = new UserLog()) {
$log->username = $username;
$log->action = "Create";
$log->object_class = "User";
$log->created_at = $now;
$log->is_success = 0;
$log->save();
}
$model->created_at = $now;
$model->dob = strtotime($model->dob);
do {
$path = FileUtils::generatePath($now);
} while (file_exists(Yii::$app->params['images_folder'] . $path));
$model->image_path = $path;
$targetFolder = Yii::$app->params['images_folder'] . $model->image_path;
$targetUrl = Yii::$app->params['images_url'] . $model->image_path;
if (!empty($data['user-image'])) {
$copyResult = FileUtils::copyImage(['imageName' => $model->image, 'fromFolder' => Yii::$app->params['uploads_folder'], 'toFolder' => $targetFolder, 'resize' => [[120, 120], [200, 200]], 'resizeType' => 2, 'removeInputImage' => true]);
if ($copyResult['success']) {
$model->image = $copyResult['imageName'];
}
}
// User class
$model->generateAuthKey();
$model->setPassword($model->password);
if ($model->save()) {
if ($log) {
$log->object_pk = $model->id;
$log->is_success = 1;
$log->save();
}
return $model;
}
$model->getErrors();
return $model;
}
return false;
}