app/library/Auth/Auth.php: in login() accept both username and email.
This commit is contained in:
parent
cf92cfe37a
commit
4d5066f5da
1 changed files with 10 additions and 4 deletions
|
|
@ -12,13 +12,19 @@ class Auth extends Component
|
||||||
*/
|
*/
|
||||||
protected $_session_key = 'auth';
|
protected $_session_key = 'auth';
|
||||||
|
|
||||||
public function login($email, $password)
|
/**
|
||||||
|
* Login using email/user + password combination.
|
||||||
|
*
|
||||||
|
* @param string $email_username
|
||||||
|
* @param string $password
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function login($email_username, $password)
|
||||||
{
|
{
|
||||||
// Look for a user with this email.
|
// Look for a user with this username/email.
|
||||||
$user = User::findFirstByEmail($email);
|
$user = User::findFirstByUsernameOrEmail($email_username);
|
||||||
|
|
||||||
if ($user) {
|
if ($user) {
|
||||||
|
|
||||||
// Verify password
|
// Verify password
|
||||||
$hash = $user->getPassword();
|
$hash = $user->getPassword();
|
||||||
if (strlen($hash) > 1 && password_verify($password, $hash)) {
|
if (strlen($hash) > 1 && password_verify($password, $hash)) {
|
||||||
|
|
|
||||||
Reference in a new issue