diff --git a/app/Models/Pages/Auth.php b/app/Models/Pages/Auth.php index 846ad7c1a323f7deebb180db66c1592a7782274d..bafd597375ca09ca5bd6d3693a2d701923a487b3 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 cbd7d9ce71ea20d98eaab8f2bee7cc370275c35f..cd1aabe0727ef2020282836f8bed5d8bc8330670 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 079db128a57bce5a87e44e7d7503e6c07d67fffc..ac3f1362f86e2a7a9afc187ac9acec557ecedfbb 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 "Имя или почта"