浏览代码

Update Profile\Email page for auto calc {hash}

Visman 4 年之前
父节点
当前提交
985e24d6cd
共有 1 个文件被更改,包括 3 次插入3 次删除
  1. 3 3
      app/Models/Pages/Profile/Email.php

+ 3 - 3
app/Models/Pages/Profile/Email.php

@@ -26,7 +26,7 @@ class Email extends Profile
     {
         if (
             $this->user->id !== $args['id']
-            || ! \hash_equals($args['hash'], $this->c->Secury->hash($args['id'] . $args['email'] . $args['key']))
+            || ! $this->c->Csrf->verify($args['hash'], 'SetNewEmail', $args)
             || ! \hash_equals($this->user->activate_string, $args['key'])
         ) {
             return $this->c->Message->message('Bad request', false);
@@ -131,15 +131,15 @@ class Email extends Profile
                             ->page('EditUserProfile', $args)
                             ->message('Email changed redirect');
                     } else {
+                        $this->c->Csrf->setHashExpiration(259200); // ???? хэш действует 72 часа
+
                         $key  = $this->c->Secury->randomPass(33);
-                        $hash = $this->c->Secury->hash($this->curUser->id . $v->new_email . $key);
                         $link = $this->c->Router->link(
                             'SetNewEmail',
                             [
                                 'id'    => $this->curUser->id,
                                 'email' => $v->new_email,
                                 'key'   => $key,
-                                'hash'  => $hash,
                             ]
                         );
                         $tplData = [