本文整理汇总了PHP中common\models\User::generateAuthKey方法的典型用法代码示例。如果您正苦于以下问题:PHP User::generateAuthKey方法的具体用法?PHP User::generateAuthKey怎么用?PHP User::generateAuthKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common\models\User
的用法示例。
在下文中一共展示了User::generateAuthKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: reg
public function reg()
{
$user = new User();
$user->phone = $this->phone;
$user->email = $this->email;
$user->status = $this->status;
$user->setPassword($this->password);
$user->generateAuthKey();
if ($this->scenario === 'emailActivation') {
$user->generateSecretKey();
}
$transaction = Yii::$app->db->beginTransaction();
try {
if ($user->save()) {
$modelProfile = new Profile();
$modelProfile->user_id = $user->id;
if ($modelProfile->save()) {
$transaction->commit();
return RbacHelper::assignRole($user->getId()) ? $user : null;
}
} else {
return false;
}
} catch (Exception $e) {
$transaction->rollBack();
}
}
示例2: signup
/**
* Signs user up.
*
* @return User|null the saved model or null if saving fails
*/
public function signup()
{
if ($this->validate()) {
$user = new Admin();
$user->fname = $this->fname;
$user->lname = $this->lname;
$user->contact_no = $this->contact_no;
$user->username = $this->username;
$user->email = $this->email;
$user->setPassword($this->password);
$user->company_name = $this->company_name;
$user->company_description = $this->company_description;
$user->shipping_address = $this->shipping_address;
$user->generateAuthKey();
$user1 = new User();
$user1->fname = $this->fname;
$user1->lname = $this->lname;
$user1->contact_no = $this->contact_no;
$user1->username = $this->username;
$user1->email = $this->email;
$user1->setPassword($this->password);
$user1->company_name = $this->company_name;
$user1->company_description = $this->company_description;
$user1->shipping_address = $this->shipping_address;
$user1->generateAuthKey();
if ($user->save() && $user1->save()) {
return $user;
return $user1;
}
}
return null;
}
示例3: actionAddData
public function actionAddData()
{
$model = new UserBackend();
$auth = new AuthAssignment();
if ($model->load(Yii::$app->request->post())) {
Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
$user = new User();
$user->username = $_POST['UserBackend']['username'];
$user->email = $_POST['UserBackend']['email'];
$user->setPassword('123456');
$user->generateAuthKey();
$user->status = 10;
if ($user) {
$auth = new AuthAssignment();
$auth->item_name = $_POST['AuthAssignment']['item_name'];
$auth->user_id = 17;
$auth->created_at = 1428931496;
if ($auth->save()) {
$res = array('message' => 'Data Berhasil Di Simpan.', 'alert' => 'success', 'proses' => 'save', 'success' => true);
} else {
$res = array('message' => 'Data Gagal Di Simpan.', 'alert' => 'error', 'proses' => 'save', 'success' => false);
}
} else {
$res = array('message' => 'Data Gagal Di Simpan.', 'alert' => 'error', 'proses' => 'save', 'success' => false);
}
return $res;
\Yii::$app->end();
} else {
return $this->renderAjax('create', ['model' => $model, 'auth' => $auth]);
}
}
示例4: register
/**
* Signs user up.
* @return User|null the saved model or null if saving fails
* @internal param string $avatar
*/
public function register()
{
if ($this->validate()) {
$user = new User(['scenario' => 'register']);
$user->username = $this->username;
$user->email = $this->email;
$user->setHashPassword($this->password);
$user->generateAuthKey();
$user->generateAccessToken();
$user->password = md5($this->password);
if ($this->saveAvatar(UploadedFile::getInstance($this, 'avatar'))) {
$user->avatar = $this->avatar;
} else {
Yii::$app->session->setFlash('alert', '注册失败');
Yii::$app->session->setFlash('alert-type', 'alert-danger');
return false;
}
if ($user->save()) {
return $user;
} else {
Yii::$app->session->setFlash('alert', '注册失败');
Yii::$app->session->setFlash('alert-type', 'alert-danger');
return false;
}
}
return null;
}
示例5: 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->gender = $this->gender;
$user->firstname = $this->firstname;
$user->lastname = $this->lastname;
$user->username = $this->email;
$user->email = $this->email;
$user->birthday = $this->birthday;
$user->user_role = $this->user_role;
$user->setPassword($this->password);
$user->generateAuthKey();
if ($user->save()) {
if ($user->user_role == 'host') {
$auth = Yii::$app->authManager;
$hostRole = $auth->getRole('host');
$auth->assign($hostRole, $user->id);
} elseif ($user->user_role == 'traveller') {
$auth = Yii::$app->authManager;
$hostRole = $auth->getRole('traveller');
$auth->assign($hostRole, $user->id);
}
return $user;
}
}
return null;
}
示例6: 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->company_id = $this->company_id;
$user->first_name = $this->first_name;
$user->last_name = $this->last_name;
$user->username = $this->username;
$user->email = $this->email;
$user->setPassword($this->password);
$user->generateAuthKey();
if ($user->save()) {
$permissionList = $_POST['SignupForm']['permissions'];
foreach ($permissionList as $value) {
$newPermissions = new AuthAssignment();
$newPermissions->user_id = $user->id;
$newPermissions->item_name = $value;
$newPermissions->save();
$newPermissions->getErrors();
}
return $user;
}
}
return null;
}
示例7: actionLogin
/**
* Logs in a user.
*
* @return mixed
*/
public function actionLogin()
{
/** @var $eauth \nodge\eauth\ServiceBase */
$eauth = Yii::$app->get('eauth')->getIdentity('steam');
$eauth->setRedirectUrl(Yii::$app->getUser()->getReturnUrl());
$eauth->setCancelUrl(Yii::$app->getUrlManager()->createAbsoluteUrl('site/login'));
try {
if ($eauth->authenticate()) {
$identity = User::findByEAuth($eauth);
$user = User::findOne(['steamid' => $identity->steamid]);
if (!$user) {
$user = new User();
}
$user->username = $identity->username;
$user->steamid = $identity->steamid;
$user->profile_url = $identity->profile_url;
$user->avatar = $identity->avatar;
$user->avatar_md = $identity->avatar_md;
$user->avatar_lg = $identity->avatar_lg;
$user->generateAuthKey();
$user->save();
Yii::$app->getUser()->login($identity);
$eauth->redirect();
} else {
$eauth->cancel();
}
} catch (ErrorException $e) {
Yii::$app->getSession()->setFlash('error', 'EAuthException: ' . $e->getMessage());
$eauth->redirect($eauth->getCancelUrl());
}
}
示例8: signupCompany
/**
* Signs company up.
*
* @return User|null the saved model or null if saving fails
*/
public function signupCompany()
{
if ($this->validate()) {
$user = new User();
$user->username = $this->name;
$user->email = $this->email;
$user->phone = $this->phone;
$user->setPassword($this->password);
$user->generateAuthKey();
$check_user = $user->save();
$service = new Service();
$service->category_id = $this->category_id;
$service->owner = $user->id;
$service->name = $this->name;
$service->phone = $this->phone;
$service->description = $this->description;
$check_service = $service->save();
if ($check_user && $check_service) {
return $user;
}
VarDumper::dump($service->getErrors(), 6, 1);
die;
}
return null;
}
示例9: 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->type = $this->type;
$user->first_name = $this->first_name;
$user->last_name = $this->last_name;
$user->full_name = $this->first_name . " " . $this->last_name;
$user->age = $this->age;
$user->gender = $this->gender;
$user->birthdate = $this->birthdate;
$user->address = $this->address;
if ($this->type == 'Student') {
$user->section_id = $this->section_id;
$user->level_id = $this->level_id;
} else {
$user->section_id = '';
$user->level_id = '';
}
$user->email = $this->email;
$user->setPassword($this->password);
$user->generateAuthKey();
if ($user->save()) {
Yii::$app->session->setFlash('success');
} else {
Yii::$app->session->setFlash('failed');
}
}
return null;
}
示例10: 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();
$user->status = 0;
if ($user->save()) {
$notification = new Notification();
$notification->title = 'user';
$notification->message = 'new user, username:' . $user->username;
$notification->params = \yii\helpers\Json::encode(['model' => 'User', 'id' => $user->id]);
if ($notification->save()) {
$this->sendEmail($this->email);
} else {
print_r($notification->getErrors());
exit(0);
}
return $user;
} else {
return $user->getErrors();
}
}
return null;
}
示例11: 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();
$user->status = User::STATUS_NOTACTIVATED;
$b = $user->save();
$activationToken = new UserTokens();
$activationToken->user_id = $user->id;
$activationToken->token_type = ETokenType::ACCOUNT_ACTIVATION;
$activationToken->token = sha1(mt_rand(10000, 99999) . time() . $user->email);
$activationToken->save();
$auth = Yii::$app->authManager;
$userRole = $auth->getRole('user');
$auth->assign($userRole, $user->id);
if ($b) {
$x = new UserInfo();
$x->user_id = $user->id;
$x->save();
EventService::createEvent(EEvent::ACCOUNT_CREATE(), new UserId($user->id));
$this->sendActivationMail($user, $activationToken->token);
return $user;
}
}
return null;
}
示例12: 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();
// Add field for project lifeguard 9/2015
$user->code = $this->code;
$user->referrer = $this->referrer;
$user->first_name = $this->first_name;
$user->last_name = $this->last_name;
$user->sex = $this->sex;
$user->graduate_high_school = $this->graduate_high_school;
$user->city = $this->city;
$user->state = $this->state;
$user->zip = $this->zip;
$user->mobile = $this->mobile;
$user->status = $this->status;
if (!$user->save()) {
throw new ErrorException("Error save information user");
}
return $user;
}
return null;
}
示例13: signup
/**
* Signs user up.
*
* @return User|null the saved model or null if saving fails
*/
public function signup()
{
if ($this->validate()) {
$user = new User();
$model = new SignupForm();
$user->firstname = $this->firstname;
$user->lastname = $this->lastname;
$user->clubname = $this->clubname;
$user->phonenumber = $this->phonenumber;
$user->mobilenumber = $this->mobilenumber;
$user->dateofbirth = $this->dateofbirth;
$user->address = $this->address;
$user->description = $this->description;
$model->file = UploadedFile::getInstance($model, 'file');
if ($model->file) {
$model->file->saveAs('uploads/' . $model->file->name);
$user->image = $model->file->name;
}
$user->username = $this->username;
$user->email = $this->email;
$user->setPassword($this->password);
$user->generateAuthKey();
if ($user->save()) {
return $user;
}
}
return null;
}
示例14: signup
/**
* Регистрация нового пользователя
*
* @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;
$randLength = mt_rand(6, 9);
$this->password = Yii::$app->security->generateRandomString($randLength);
$user->setPassword($this->password);
$user->generateAuthKey();
if ($user->save()) {
//$profile = new Profile();
//$profile->user_id = $user->id;
//$profile->name = $this->name;
////если в куках есть id аффилиата, сохраняем его
//$affiliateId = (int) Yii::$app->request->cookies['affiliate'];
//if ($affiliateId > 0 && User::findIdentity($affiliateId)) {
//$profile->user_affiliate_id = $affiliateId;
//}
//$profile->save();
// Присвоить роль пользователю можно при создании нового пользователя.
// присвоить Роль "user" новому пользователю
// `auth_assignment`
$userRole = Yii::$app->authManager->getRole('user');
Yii::$app->authManager->assign($userRole, $user->getId());
return $this->sendRegistrationEmail();
}
}
return null;
}
示例15: 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->nama = $this->nama;
$user->email = $this->email;
$user->setPassword($this->password);
$user->tanggal_lahir = $this->tanggal_lahir;
$user->fakultas = $this->fakultas;
$user->jurusan = $this->jurusan;
$user->angkatan = $this->angkatan;
$user->pekerjaan = $this->pekerjaan;
$user->alamat_rumah = $this->alamat_rumah;
$user->alamat_domilisi = $this->alamat_domilisi;
$user->no_hp = $this->no_hp;
$user->id_line = $this->id_line;
$user->foto = 'uploads/' . $this->foto;
$user->generateAuthKey();
if ($user->save()) {
return $user;
}
}
return null;
}