Pman/Login.php
[Pman.Base] / Pman / Login.php
index f0c30aa..5feeb62 100644 (file)
@@ -131,7 +131,7 @@ class Pman_Login extends Pman
         $u = DB_DataObject::factory($tbl);
         $s = DB_DataObject::factory('core_setting');
         $require_oath_val = 1;
-        $require_oath = $s->lookup('core', 'two_factor_authentication_requirement');
+        $require_oath = $s->lookup('core', 'two_factor_auth_required');
         if(!empty($require_oath)) {
             if($require_oath->val == 0) {
                 $require_oath_val = 0;
@@ -140,8 +140,7 @@ class Pman_Login extends Pman
         
         if (!$u->isAuth()) {
             $this->jok(array(
-                'id' => 0,
-                'require_oath' => 0
+                'id' => 0
             ));
             exit;
         }
@@ -328,9 +327,11 @@ class Pman_Login extends Pman
         
         if(
             !empty($u->oath_key) &&
-           empty($_REQUEST['oath_password']) &&
-            !$u->checkTwoFactorAuthentication($_REQUEST['oath_password'])
-        ){
+           (
+               empty($_REQUEST['oath_password']) ||
+               !$u->checkTwoFactorAuthentication($_REQUEST['oath_password'])
+           )
+        ) {
             $this->jerror('LOGIN-BAD', 'You typed the wrong Username or Password  (3)');
             exit;
         }
@@ -415,13 +416,18 @@ class Pman_Login extends Pman
         $this->bcc = $bcc;
         $this->rcpts = $u->getEmailFrom();
         
-        $ret = $cm->send($this);
-        //$this->jerr(print_r($r->toData(),true));
-        
-        if (is_object($ret)) {
-            $this->addEvent('SYSERR',false, $ret->getMessage());
+       
+       $mailer = $cm->toMailer($this, false);
+       if (is_a($mailer,'PEAR_Error') ) {
+           $this->addEvent('SYSERR',false, $mailer->getMessage());
+           $this->jerr($mailer->getMessage());
+       }
+        $sent = $mailer->send();
+       if (is_a($sent,'PEAR_Error') ) {
+           $this->addEvent('SYSERR',false, $sent->getMessage());
             $this->jerr($ret->getMessage());
         }
+       
         $this->addEvent('PASSREQ',$u, $u->email);
         $uu = clone($u);
         $uu->no_reset_sent++;