當前位置: 首頁>>代碼示例>>PHP>>正文


PHP User::generateAuthKey方法代碼示例

本文整理匯總了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();
     }
 }
開發者ID:baranov-nt,項目名稱:some-2,代碼行數:27,代碼來源:RegForm.php

示例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;
 }
開發者ID:pdbangibang,項目名稱:apc-softdev-gd121mi122-4,代碼行數:37,代碼來源:SignupForm.php

示例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]);
     }
 }
開發者ID:cakpep,項目名稱:spk-tht,代碼行數:31,代碼來源:UserController.php

示例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;
 }
開發者ID:kangqf,項目名稱:kblog_with_yii2,代碼行數:32,代碼來源:RegisterForm.php

示例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;
 }
開發者ID:Junaid-Farid,項目名稱:staylance-new,代碼行數:33,代碼來源:SignupForm.php

示例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;
 }
開發者ID:hendrasyp,項目名稱:YII2-Setup,代碼行數:30,代碼來源:SignupForm.php

示例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());
     }
 }
開發者ID:CyanoFresh,項目名稱:Yii2-steam-login,代碼行數:36,代碼來源:SiteController.php

示例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;
 }
開發者ID:BayramovNicat,項目名稱:toyplan,代碼行數:30,代碼來源:SignupForm.php

示例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;
 }
開發者ID:kbchong,項目名稱:projectwork,代碼行數:36,代碼來源:SignupForm.php

示例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;
 }
開發者ID:sintret,項目名稱:yii2-advanced,代碼行數:32,代碼來源:SignupForm.php

示例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;
 }
開發者ID:lupi-stole-my-code,項目名稱:nzi-project,代碼行數:34,代碼來源:SignupForm.php

示例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;
 }
開發者ID:ncuong,項目名稱:lifeguard,代碼行數:32,代碼來源:SignupForm.php

示例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;
 }
開發者ID:praveen-tissera,項目名稱:Horsebuzz,代碼行數:33,代碼來源:SignupForm.php

示例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;
 }
開發者ID:bxgsmart,項目名稱:korsun-yii2-web-monitoring,代碼行數:35,代碼來源:SignupForm.php

示例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;
 }
開發者ID:andrikurniawan,項目名稱:immmweb,代碼行數:30,代碼來源:SignupForm.php


注:本文中的common\models\User::generateAuthKey方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。