Explorar o código

Update Pages\Auth for auto calc {hash}

Visman %!s(int64=4) %!d(string=hai) anos
pai
achega
c0809de7fd
Modificáronse 1 ficheiros con 3 adicións e 3 borrados
  1. 3 3
      app/Models/Pages/Auth.php

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

@@ -250,14 +250,14 @@ class Auth extends Page
                     $v->validation($_POST)
                     && 0 === $this->c->bans->banFromName($tmpUser->username)
                 ) {
+                    $this->c->Csrf->setHashExpiration(259200); // ???? хэш действует 72 часа
+
                     $key  = $this->c->Secury->randomPass(32);
-                    $hash = $this->c->Secury->hash($tmpUser->id . $key);
                     $link = $this->c->Router->link(
                         'ChangePassword',
                         [
                             'id'   => $tmpUser->id,
                             'key'  => $key,
-                            'hash' => $hash,
                         ]
                     );
                     $tplData = [
@@ -362,7 +362,7 @@ class Auth extends Page
     public function changePass(array $args, string $method): Page
     {
         if (
-            ! \hash_equals($args['hash'], $this->c->Secury->hash($args['id'] . $args['key']))
+            ! $this->c->Csrf->verify($args['hash'], 'ChangePassword', $args)
             || ! ($user = $this->c->users->load($args['id'])) instanceof User
             || ! \hash_equals($user->activate_string, $args['key'])
         ) {