本文整理汇总了PHP中app\models\User::findByLogin方法的典型用法代码示例。如果您正苦于以下问题:PHP User::findByLogin方法的具体用法?PHP User::findByLogin怎么用?PHP User::findByLogin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\User
的用法示例。
在下文中一共展示了User::findByLogin方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUser
/**
* Finds user by [[email]]
*
* @return User|null
*/
public function getUser()
{
if ($this->_user === false) {
$this->_user = User::findByLogin($this->email);
}
return $this->_user;
}
示例2: login
public function login()
{
$user = User::findByLogin($this->login);
if ($this->validate() && $user) {
return Yii::$app->user->login($user, 3600 * 24 * 30);
} else {
return false;
}
}
示例3: getUser
public function getUser()
{
if ($this->_user === false) {
if ($this->scenario === 'loginWithEmail') {
$this->_user = User::findByEmail($this->email);
} else {
$this->_user = User::findByLogin($this->login);
}
}
return $this->_user;
}
示例4: behaviors
/**
* @return array
*/
public function behaviors()
{
$behaviors = parent::behaviors();
$behaviors['authenticator'] = ['class' => CompositeAuth::className(), 'authMethods' => [['class' => HttpBasicAuth::className(), 'auth' => function ($username, $password) {
$user = User::findByLogin($username);
var_dump($user);
die;
return $user->validatePassword($password) ? $user : null;
}]]];
$behaviors['authenticator'] = ['class' => HttpBasicAuth::className()];
return $behaviors;
}
示例5: actionRestorepass
public function actionRestorepass()
{
if (!($post = \Yii::$app->getRequest()->getBodyParams())) {
throw new \yii\web\HttpException(400, 'Дані не отримані');
}
$model = User::findByLogin($post['login']);
if (!$model->login) {
throw new \yii\web\HttpException(400, 'Даного користувача не існує');
}
$model->generatePasswordResetToken();
$url = 'http://localhost/home/web-client/#/restorepassword?u=' . $model->login . '&p=' . $model->password_reset_token;
\Yii::$app->mailer->compose()->setFrom('localhost@gmail.com')->setTo($model->email)->setSubject('Відновлення паролю')->setTextBody('')->setHtmlBody("<b><a href=\"{$url}\">{$url}</a></b>")->send();
$model->save();
return true;
}
示例6: actionCheckUnique
/**
* Checks whether email or login is unique
*/
public function actionCheckUnique()
{
$post = Yii::$app->request->post();
switch ($post['field']) {
case 'email':
$isUnique = User::findByEmail($post['value']) === null;
break;
case 'login':
$isUnique = User::findByLogin($post['value']) === null;
break;
default:
break;
}
Yii::$app->response->format = 'json';
return ["result" => $isUnique];
}