소스 검색

Change passphrase recovery

Visman 5 년 전
부모
커밋
2d41ecebb5
2개의 변경된 파일6개의 추가작업 그리고 6개의 파일을 삭제
  1. 1 1
      app/Controllers/Routing.php
  2. 5 5
      app/Models/Pages/Auth.php

+ 1 - 1
app/Controllers/Routing.php

@@ -40,7 +40,7 @@ class Routing
             // забыли кодовую фразу
             $r->add(['GET', 'POST'],  '/login/forget', 'Auth:forget', 'Forget');
             // смена кодовой фразы
-            $r->add(['GET', 'POST'],  '/login/{email}/{key}/{hash}', 'Auth:changePass', 'ChangePassword');
+            $r->add(['GET', 'POST'],  '/login/{id:\d+}/{key}/{hash}', 'Auth:changePass', 'ChangePassword');
 
             // регистрация
             if ('1' == $config->o_regs_allow) {

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

@@ -211,8 +211,8 @@ class Auth extends Page
 
             if ($v->validation($_POST)) {
                 $key  = $this->c->Secury->randomPass(32);
-                $hash = $this->c->Secury->hash($tmpUser->email . $key);
-                $link = $this->c->Router->link('ChangePassword', ['email' => $tmpUser->email, 'key' => $key, 'hash' => $hash]);
+                $hash = $this->c->Secury->hash($tmpUser->id . $key);
+                $link = $this->c->Router->link('ChangePassword', ['id' => $tmpUser->id, 'key' => $key, 'hash' => $hash]);
                 $tplData = [
                     'fRootLink' => $this->c->Router->link('Index'),
                     'fMailer'   => \ForkBB\__('Mailer', $this->c->config->o_board_title),
@@ -241,7 +241,7 @@ class Auth extends Page
 
                     return $this->c->Message->message(\ForkBB\__('Forget mail', $this->c->config->o_admin_email), false, 200);
                 } else {
-                    return $this->c->Message->message(\ForkBB\__('Error mail', $this->c->config->o_admin_email), true, 200);
+                    return $this->c->Message->message(\ForkBB\__('Error mail', $this->c->config->o_admin_email), true, 424);
                 }
             }
 
@@ -310,8 +310,8 @@ class Auth extends Page
      */
     public function changePass(array $args, $method)
     {
-        if (! \hash_equals($args['hash'], $this->c->Secury->hash($args['email'] . $args['key']))
-            || ! ($user = $this->c->users->load($this->c->users->create(['email' => $args['email']]))) instanceof User
+        if (! \hash_equals($args['hash'], $this->c->Secury->hash($args['id'] . $args['key']))
+            || ! ($user = $this->c->users->load((int) $args['id'])) instanceof User
             || $user->isGuest
             || empty($user->activate_string)
             || ! \hash_equals($user->activate_string, $args['key'])