Pman/Login.php
authorAlan Knowles <alan@roojs.com>
Fri, 7 Dec 2018 02:40:24 +0000 (10:40 +0800)
committerAlan Knowles <alan@roojs.com>
Fri, 7 Dec 2018 02:40:24 +0000 (10:40 +0800)
Pman/Login.php

index ed06d38..536f392 100644 (file)
@@ -460,6 +460,34 @@ class Pman_Login extends Pman
         $uu->update($u);
         $this->jok("done");
         
+    }
+    
+    function verifyResetPassword($id,$t, $key)
+    {
+       $au = $this->getAuthUser();
+        if ($au) {
+            $this->jerr( "Already Logged in - no need to use Password Reset");
+        }
+        
+        $u = DB_DataObject::factory('core_person');
+        //$u->company_id = $this->company->id;
+        $u->active = 1;
+        if (!$u->get($id) || !strlen($u->passwd)) {
+            $this->jerr("Password reset link is not valid (id)");
+        }
+        
+        // validate key.. 
+        if ($key != $u->genPassKey($t)) {
+            $this->jerr("Password reset link is not valid ($key)");
+        }
+       
+       if ($t < strtotime("NOW - 1 DAY")) {
+            $this->jerr("Password reset link has expired");
+        }
+       return true;
+       
+       
+       
     }
     
     
@@ -468,7 +496,7 @@ class Pman_Login extends Pman
         
         $au = $this->getAuthUser();
         if ($au) {
-            return "Already Logged in - no need to use Password Reset";
+            $this->jerr( "Already Logged in - no need to use Password Reset");
         }
         
         $u = DB_DataObject::factory('core_person');