Selaa lähdekoodia

Added login via email/password

Visman 2 vuotta sitten
vanhempi
commit
cdb41fa93c
3 muutettua tiedostoa jossa 14 lisäystä ja 2 poistoa
  1. 8 2
      app/Models/Pages/Auth.php
  2. 3 0
      app/lang/en/auth.po
  3. 3 0
      app/lang/ru/auth.po

+ 8 - 2
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 (

+ 3 - 0
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"

+ 3 - 0
app/lang/ru/auth.po

@@ -65,3 +65,6 @@ msgstr "Ваша кодовая фраза изменена. Вы можете 
 
 msgid "Account activated"
 msgstr "Аккаунт активирован."
+
+msgid "Username or email"
+msgstr "Имя или почта"