本文整理汇总了PHP中app\models\User::findByEmail方法的典型用法代码示例。如果您正苦于以下问题:PHP User::findByEmail方法的具体用法?PHP User::findByEmail怎么用?PHP User::findByEmail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\User
的用法示例。
在下文中一共展示了User::findByEmail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findUser
/**
* @param $userEmail
*
* @return null|static|User
*/
protected function findUser($userEmail)
{
if (!($user = User::findByEmail($userEmail))) {
throw new InvalidParamException("Not found user by email {$userEmail}");
}
return $user;
}
示例2: actionIndex
public function actionIndex()
{
if (Yii::$app->user->isGuest) {
$model = new IndexForm();
if ($model->load(Yii::$app->request->post()) && $model->validate()) {
if ($link = $model->generateLink()) {
if (User::findByEmail($link->email)) {
$url = Yii::$app->urlManager->createAbsoluteUrl(['/site/login', 'token' => $link->token]);
} else {
$url = Yii::$app->urlManager->createAbsoluteUrl(['/site/reg', 'token' => $link->token]);
}
if ($model->sendMail($url, $link->email)) {
Yii::$app->session->setFlash('warning', 'Check your email');
return $this->redirect('/site/index');
}
} else {
Yii::$app->session->setFlash('error', 'Error generate link.');
Yii::error('Error generate link');
return $this->refresh();
}
}
return $this->render('index', ['model' => $model]);
}
return $this->redirect('/account/index');
}
示例3: getUser
/**
* Finds user by [[email]]
*
* @return User|null
*/
public function getUser()
{
if ($this->_user === false) {
$this->_user = User::findByEmail($this->email);
}
return $this->_user;
}
示例4: getUser
public function getUser()
{
if ($this->_user === false) {
// $this->_user = User::findByUsername($this->username);
$this->_user = User::findByEmail($this->email);
}
return $this->_user;
}
示例5: findUser
public function findUser()
{
$this->_user = User::findByEmail($this->email);
if (!$this->_user) {
return false;
}
return true;
}
示例6: getUser
/**
* Finds user by [[username]]
*
* @return User|null
*/
public function getUser()
{
if ($this->_user === false) {
$this->_user = User::findByUsername($this->username);
if (is_null($this->_user)) {
$this->_user = User::findByEmail($this->username);
}
}
return $this->_user;
}
示例7: testSuccess
public function testSuccess()
{
$user = User::findByEmail('superuser@example.com');
expect_not($user->isConfirmed());
$form = new ConfirmEmailForm();
expect_that($form->validateToken($user->email_confirm_token));
expect_that($form->confirmEmail());
$user = User::findByEmail($user->email);
expect($user->email_confirm_token)->isEmpty();
expect_that($user->isConfirmed());
}
示例8: testSuccess
public function testSuccess()
{
$user = $this->tester->grabFixture('user', 'user-1');
$form = new ResetPasswordForm();
$form->password = 'password-new';
expect_that($form->validateToken($user->password_reset_token));
expect_that($form->resetPassword());
$user = User::findByEmail($user->email);
expect($user->password_reset_token)->isEmpty();
expect_that($user->validatePassword('password-new'));
}
示例9: getUser
public function getUser()
{
if ($this->_user === false) {
if ($this->scenario === 'loginWithEmail') {
$this->_user = User::findByEmail($this->email);
} else {
$this->_user = User::findByUsername($this->username);
}
}
return $this->_user;
}
示例10: sendEmail
/**
* Send password reset instructions.
* @return boolean
*/
public function sendEmail()
{
$user = User::findByEmail($this->email);
if ($user && $user->status === User::STATUS_ENABLED) {
$user->generatePasswordResetToken();
if ($user->save()) {
return $this->mail('passwordRequest', $this->email, ['subject' => Yii::t('app', 'Reset password information for {name} at {site}', ['name' => $user->name, 'site' => Yii::$app->name]), 'user' => $user]);
}
}
return false;
}
示例11: login
public function login()
{
if ($this->validate()) {
if (!($user = User::findByUsername($this->username))) {
$user = User::findByEmail($this->username);
}
if ($login = \Gbox::$components->user->login($user, $this->rememberMe ? 3600 * 24 * 30 : 0)) {
}
return $login;
}
return false;
}
示例12: actionIndex
public function actionIndex()
{
$params = Yii::$app->request->getBodyParams();
$user = User::findByEmail(Yii::$app->request->getBodyParam('email'));
if (!$user) {
return ['success' => 0, 'message' => 'No such user found'];
}
$valid = $user->validatePassword(Yii::$app->request->getBodyParam('password'));
if (!$valid) {
return ['success' => 0, 'message' => 'Incorrect password'];
}
return ['success' => 1, 'payload' => $user];
}
示例13: authenticate
public function authenticate($data)
{
$user = User::findByEmail($data->email);
if (empty($user)) {
throw new Exception('Такой пользователь не существует', self::ERROR_INVALID_EMAIL);
}
if (!\T4\Crypt\Helpers::checkPassword($data->password, $user->password)) {
throw new Exception('Неверный пароль', self::ERROR_INVALID_PASSWORD);
}
$this->login($user);
Application::getInstance()->user = $user;
return $user;
}
示例14: restorePsw
public function restorePsw()
{
$user = User::findByEmail($this->email);
if ($user) {
if ($user->password_reset_token === '') {
$user->password_reset_token = Yii::$app->security->generateRandomString();
$user->save();
}
$this->sendEmail($this->email, $user->id, $user->password_reset_token);
return true;
}
return false;
}
示例15: resetPassword
public function resetPassword()
{
if ($this->validate()) {
$user = User::findByEmail($this->email, true);
if (is_null($user)) {
$this->addError('email', '无效的邮箱');
return false;
}
$user->salt = Str::random(10);
$user->password = $user->generatePassword($this->password);
return $user->save();
}
$this->addError('password', '重置密码失败');
return false;
}