Browse Source

Update Validator\Email

Add nosoloban flag.
Visman 4 years ago
parent
commit
0fbeb59eea
3 changed files with 21 additions and 6 deletions
  1. 1 1
      app/Models/Pages/Auth.php
  2. 1 1
      app/Models/Pages/Register.php
  3. 19 4
      app/Models/Validators/Email.php

+ 1 - 1
app/Models/Pages/Auth.php

@@ -241,7 +241,7 @@ class Auth extends Page
 
                 $v = $v->reset()
                     ->addRules([
-                        'email' => 'required|string:trim|email:noban,exists,flood',
+                        'email' => 'required|string:trim|email:nosoloban,exists,flood',
                     ])->addArguments([
                         'email.email' => $tmpUser, // сюда идет возрат данных по найденному пользователю
                     ]);

+ 1 - 1
app/Models/Pages/Register.php

@@ -32,7 +32,7 @@ class Register extends Page
                 'token'    => 'token:RegisterForm',
                 'agree'    => 'required|token:Register',
                 'on'       => 'integer',
-                'email'    => 'required_with:on|string:trim|email:noban', // ???? noban
+                'email'    => 'required_with:on|string:trim|email:noban',
                 'username' => 'required_with:on|string:trim|username',
                 'password' => 'required_with:on|string|min:16|password',
                 'register' => 'required|string',

+ 19 - 4
app/Models/Validators/Email.php

@@ -58,11 +58,26 @@ class Email extends RulesValidator
         // провеерка бана email
         if (
             $ok
-            && isset($attrs['noban'])
-            && $this->c->bans->isBanned($user) > 0
+            && (
+                isset($attrs['noban'])
+                || isset($attrs['nosoloban'])
+            )
         ) {
-            $v->addError('Banned email');
-            $ok = false;
+            $banType = $this->c->bans->isBanned($user);
+
+            if (
+                $banType > 0
+                && (
+                    isset($attrs['noban'])
+                    || (
+                        1 === $banType
+                        && isset($attrs['nosoloban'])
+                    )
+                )
+            ) {
+                $v->addError('Banned email');
+                $ok = false;
+            }
         }
         // проверка наличия 1 пользователя с этим email
         if (