DataObjects/Core_person.php
authoredward <edward@roojs.com>
Fri, 3 Nov 2017 05:44:32 +0000 (13:44 +0800)
committeredward <edward@roojs.com>
Fri, 3 Nov 2017 05:44:32 +0000 (13:44 +0800)
DataObjects/Core_person.php

index 547b5c6..73edeab 100644 (file)
@@ -519,6 +519,24 @@ class Pman_Core_DataObjects_Core_person extends DB_DataObject
         
         return md5(implode(',' ,  array($month, $this->email , $this->passwd, $this->id)));
     } 
+    
+    function checkTwoFactorAuthentication($val)
+    {
+        require_once 'System.php';
+        
+        $oathtool = System::which('oathtool');
+        
+        if (!$oathtool) {
+            return false;
+        }
+        
+        $cmd = "{$oathtool} --totp --base32 {$this->oath_key}";
+        
+        $password = exec($cmd);
+        
+        return ($password == $val) ? true : false;
+    }
+    
     function checkPassword($val)
     {
         if (substr($this->passwd,0,1) == '$') {