Skip to content

Commit

Permalink
Fixed User's findByUsernameOrEmail method.
Browse files Browse the repository at this point in the history
  • Loading branch information
maddoger committed Nov 5, 2015
1 parent d023705 commit 6792d1d
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions common/models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,17 +373,12 @@ public static function findByEmail($email, $checkStatus = true)
*/
public static function findByUsernameOrEmail($username, $checkStatus = true)
{
return static::findOne(
$checkStatus ?
[
'and',
['or', 'username' => $username, 'email' => $username],
'status' => self::STATUS_ACTIVE
] :
[
['or', 'username' => $username, 'email' => $username],
]
);
$query = static::find();
$query->where(['or', ['username' => $username], ['email' => $username]]);
if ($checkStatus) {
$query->andWhere(['status' => self::STATUS_ACTIVE]);
}
return $query->limit(1)->one();
}

/**
Expand Down

0 comments on commit 6792d1d

Please sign in to comment.