本文整理汇总了PHP中app\modules\user\models\User::generateEmailConfirmToken方法的典型用法代码示例。如果您正苦于以下问题:PHP User::generateEmailConfirmToken方法的具体用法?PHP User::generateEmailConfirmToken怎么用?PHP User::generateEmailConfirmToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\modules\user\models\User
的用法示例。
在下文中一共展示了User::generateEmailConfirmToken方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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->last_name = $this->last_name;
$user->first_name = $this->first_name;
$user->patronymic = $this->patronymic;
$user->email_work = $this->email_work;
$user->post_id = $this->post_id;
$user->department_id = $this->department_id;
$user->status_id = User::STATUS_WAIT;
$user->setPassword($this->password);
$user->generateAuthKey();
$user->generateEmailConfirmToken();
if ($user->save()) {
// Присваиваем роль по умолчанию
//$auth = Yii::$app->authManager;
//$authorRole = $auth->getRole('user');
//$auth->assign($authorRole, $user->getId());
//Отправляем письмо с подтверждением
/*Yii::$app->mailer->compose('confirmEmail', ['user' => $user])
->setFrom([Yii::$app->params['app']['supportEmail'] => Yii::$app->params['app']['title']])
->setTo($this->email_work)
->setSubject('Email confirmation for ' . Yii::$app->name)
->send();
*/
Yii::$app->mailer->compose('confirmEmail', ['user' => $user])->setFrom([Yii::$app->params['app']['email'] => Yii::$app->params['app']['title']])->setTo($this->email_work)->setSubject('Email confirmation for ')->send();
}
return $user;
}
return null;
}
示例2: signup
public function signup()
{
if ($this->validate()) {
$user = new User();
$user->username = $this->username;
$user->email = $this->email;
$user->setPassword($this->password);
$user->status = User::STATUS_WAIT;
$user->generateAuthKey();
$user->generateEmailConfirmToken();
if ($user->save()) {
$auth = Yii::$app->authManager;
$userRoleDefault = $auth->getRole('user');
$auth->assign($userRoleDefault, $user->getId());
$userProfile = new Profile();
$userProfile->user_id = $user->getId();
$userProfile->user_agent = Yii::$app->request->getUserAgent();
$userProfile->user_ip = Yii::$app->request->getUserIP();
$userProfile->name = $user->username;
$userProfile->avatar_id = 1;
//default.png (id = 1)
$userProfile->save(false);
Yii::$app->mailer->compose(['text' => '@app/modules/user/mails/emailConfirm'], ['user' => $user])->setFrom([Yii::$app->params['supportEmail'] => Yii::$app->name . ' robot'])->setTo($this->email)->setSubject(Module::t('app', 'EMAIL_SIGNUP_SUBJECT') . Yii::$app->name)->send();
}
return $user;
}
return null;
}
示例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->status = User::STATUS_WAIT;
$user->generateAuthKey();
$user->generateEmailConfirmToken();
//
if ($user->save()) {
$auth = Yii::$app->authManager;
$role = $auth->getRole('client');
$auth->assign($role, $user->getId());
$confirmLink = Yii::$app->urlManager->createAbsoluteUrl(['user/default/confirm-email', 'token' => $user->email_confirm_token]);
$message = "Здравствуйте, " . Html::encode($user->username) . "!";
$message .= "Для подтверждения адреса пройдите по ссылке:";
//$message .= Html::a(Html::encode($confirmLink), $confirmLink) ;
$message .= $confirmLink;
$message .= " Если Вы не регистрировались у на нашем сайте, то просто удалите это письмо.";
// Отправляем
mail($user->email, 'Регистрация на сайте', $message);
// $mailer =Yii::$app->get('mailsmtp');
//
// $message =$mailer->compose('confirmEmail', ['user' => $user])
//
// ->setTo($this->email)
// ->setFrom([Yii::$app->params['supportEmail'] => Yii::$app->name])
// ->setSubject('Email confirmation for ' . Yii::$app->name);
//
// $message->getSwiftMessage()->getHeaders()->addTextHeader('name', 'value');
// $failures =null;
// try {
//
// if(!$mailer->send($message, $failures)) $errorCode=$failures; //отправляем
//
// }catch (\Swift_TransportException $e) { //проверяем на ошибки
// $pattern = '|got code "(.+?)", with|is';
// preg_match($pattern, $e->getMessage(), $out);
// $errorCode=$out[1];
// }
/*Yii::$app->mailer->compose('confirmEmail', ['user' => $user])
->setFrom([Yii::$app->params['supportEmail'] => Yii::$app->name])
->setTo($this->email)
->setSubject('Email confirmation for ' . Yii::$app->name)
->send();*/
}
return $user;
}
return null;
}
示例4: 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->status = User::STATUS_WAIT;
$user->generateAuthKey();
$user->generateEmailConfirmToken();
if ($user->save()) {
Yii::$app->mailer->compose('confirmEmail', ['user' => $user])->setFrom([Yii::$app->params['supportEmail'] => Yii::$app->name])->setTo($this->email)->setSubject('Email confirmation for ' . Yii::$app->name)->send();
}
return $user;
}
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->username = $this->username;
$user->email = $this->email;
$user->setPassword($this->password);
$user->status = User::STATUS_WAIT;
$user->generateAuthKey();
$user->generateEmailConfirmToken();
if ($user->save()) {
Yii::$app->mailer->compose(['text' => '@app/modules/user/mails/emailConfirm'], ['user' => $user])->setFrom([Yii::$app->params['supportEmail'] => Yii::$app->name])->setTo($this->email)->setSubject(Module::t('module', 'EMAIL_CONFIRMATION_FOR {appName}', ['appName' => Yii::$app->name]))->send();
}
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->username = $this->username;
$user->email = $this->email;
$user->setPassword($this->password);
$user->status = User::STATUS_ACTIVE;
// заглушка (должно быть STATUS_WAIT): из-за неполадок с отправкой e-mail на сервере
$user->generateAuthKey();
$user->generateEmailConfirmToken();
if ($user->save()) {
Yii::$app->mailer->compose('confirmEmail', ['user' => $user])->setFrom([Yii::$app->params['supportEmail'] => Yii::$app->name])->setTo($this->email)->setSubject('Email confirmation for ' . Yii::$app->name)->send();
}
return $user;
}
return null;
}
示例7: 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->status = User::STATUS_NOT_CONFIRMED;
$user->generateAuthKey();
$user->generateEmailConfirmToken();
if ($user->save()) {
$profile = new Profile();
$profile->link('user', $user);
Yii::$app->mailer->compose(['text' => '@app/modules/user/mails/emailConfirm'], ['user' => $user])->setFrom([Yii::$app->params['supportEmail'] => Yii::$app->name])->setTo($this->email)->setSubject('Email confirmation for ' . Yii::$app->name)->send();
}
return $user;
}
return null;
}
示例8: 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->status = User::STATUS_WAIT;
$user->generateAuthKey();
$user->generateEmailConfirmToken();
if ($user->save()) {
$auth = Yii::$app->authManager;
$authorRole = $auth->getRole('author');
$auth->assign($authorRole, $user->getId());
Yii::$app->mailer->compose(['text' => '@app/modules/user/mails/emailConfirm'], ['user' => $user])->setFrom([Yii::$app->params['supportEmail'] => Yii::$app->name])->setTo($this->email)->setSubject('Email confirmation for ' . Yii::$app->name)->send();
}
return $user;
}
return null;
}