本文整理汇总了PHP中dektrium\user\Finder::findUserByUsernameOrEmail方法的典型用法代码示例。如果您正苦于以下问题:PHP Finder::findUserByUsernameOrEmail方法的具体用法?PHP Finder::findUserByUsernameOrEmail怎么用?PHP Finder::findUserByUsernameOrEmail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dektrium\user\Finder
的用法示例。
在下文中一共展示了Finder::findUserByUsernameOrEmail方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionIndex
/**
* Updates user's password to given.
*
* @param string $search Email or username
* @param string $password New password
*/
public function actionIndex($search, $password)
{
$user = $this->finder->findUserByUsernameOrEmail($search);
if ($user === null) {
$this->stdout(Yii::t('user', 'User is not found') . "\n", Console::FG_RED);
} else {
if ($user->resetPassword($password)) {
$this->stdout(Yii::t('user', 'Password has been changed') . "\n", Console::FG_GREEN);
} else {
$this->stdout(Yii::t('user', 'Error occurred while changing password') . "\n", Console::FG_RED);
}
}
}
示例2: actionIndex
/**
* Confirms a user by setting confirmed_at field to current time.
*
* @param string $search Email or username
*/
public function actionIndex($search)
{
$user = $this->finder->findUserByUsernameOrEmail($search);
if ($user === null) {
$this->stdout(Yii::t('user', 'User is not found') . "\n", Console::FG_RED);
} else {
if ($user->confirm()) {
$this->stdout(Yii::t('user', 'User has been confirmed') . "\n", Console::FG_GREEN);
} else {
$this->stdout(Yii::t('user', 'Error occurred while confirming user') . "\n", Console::FG_RED);
}
}
}
示例3: actionIndex
/**
* Deletes a user.
*
* @param string $search Email or username
*/
public function actionIndex($search)
{
if ($this->confirm(\Yii::t('user', 'Are you sure? Deleted user can not be restored'))) {
$user = $this->finder->findUserByUsernameOrEmail($search);
if ($user === null) {
$this->stdout(\Yii::t('user', 'User is not found') . "\n", Console::FG_RED);
} else {
if ($user->delete()) {
$this->stdout(\Yii::t('user', 'User has been deleted') . "\n", Console::FG_GREEN);
} else {
$this->stdout(\Yii::t('user', 'Error occurred while deleting user') . "\n", Console::FG_RED);
}
}
}
}
示例4: beforeValidate
/** @inheritdoc */
public function beforeValidate()
{
if (parent::beforeValidate()) {
$this->user = $this->finder->findUserByUsernameOrEmail(trim($this->login));
return true;
} else {
return false;
}
}