diff --git a/app/Models/Pages/Auth.php b/app/Models/Pages/Auth.php index 846ad7c1..bafd5973 100644 --- a/app/Models/Pages/Auth.php +++ b/app/Models/Pages/Auth.php @@ -175,7 +175,7 @@ class Auth extends Page 'autofocus' => true, 'type' => 'text', 'value' => $username, - 'caption' => 'Username', + 'caption' => 'Username or email', 'required' => true, ], 'password' => [ @@ -209,7 +209,13 @@ class Auth extends Page { if (empty($v->getErrors())) { if ($this->loginWithForm) { - $this->userAfterLogin = $this->c->users->loadByName($v->username); + if (\strpos($v->username, '@')) { + $this->userAfterLogin = $this->c->users->loadByEmail($v->username); + } + + if (! $this->userAfterLogin instanceof User) { + $this->userAfterLogin = $this->c->users->loadByName($v->username); + } } if ( diff --git a/app/lang/en/auth.po b/app/lang/en/auth.po index cbd7d9ce..cd1aabe0 100644 --- a/app/lang/en/auth.po +++ b/app/lang/en/auth.po @@ -65,3 +65,6 @@ msgstr "Your passphrase has been updated. You can now login with your new passph msgid "Account activated" msgstr "Account activated." + +msgid "Username or email" +msgstr "Username or email" diff --git a/app/lang/ru/auth.po b/app/lang/ru/auth.po index 079db128..ac3f1362 100644 --- a/app/lang/ru/auth.po +++ b/app/lang/ru/auth.po @@ -65,3 +65,6 @@ msgstr "Ваша кодовая фраза изменена. Вы можете msgid "Account activated" msgstr "Аккаунт активирован." + +msgid "Username or email" +msgstr "Имя или почта"