Example #1
0
 /**
  * 添加日志
  *
  * @param PwLogLoginDm $dm
  * @return int
  */
 public function addLog(PwLogLoginDm $dm)
 {
     if (true !== ($r = $dm->beforeAdd())) {
         return $r;
     }
     return $this->_getLogDao()->addLog($dm->getData());
 }
Example #2
0
 /**
  * 用户登录
  *
  * @param string $username 用户登录的帐号
  * @param string $password 用户登录的密码
  * @param string $ip 登录IP
  * @param string $safeQuestion 安全问题
  * @param string $safeAnswer 安全问题答案
  * @return boolean|int
  */
 public function login($username, $password, $ip, $safeQuestion = null, $safeAnswer = '')
 {
     $checkQ = !is_null($safeQuestion) ? true : false;
     list($status, $info) = $this->auth($username, $password, $checkQ, $safeQuestion, $safeAnswer);
     switch ($status) {
         case 1:
             //用户信息正常
             if (true !== ($r = $this->allowTryAgain($info['uid'], $ip))) {
                 return $r;
             }
             break;
         case -1:
             //用户不存在
             return new PwError('USER:user.error.-14');
         case -2:
             //用户密码错误
             Wind::import('SRV:log.PwLogLogin');
             Wind::import('SRV:log.dm.PwLogLoginDm');
             $dm = new PwLogLoginDm($info['uid']);
             $dm->setUsername($info['username'])->setTypeid(PwLogLogin::ERROR_PWD)->setIp($ip)->setCreatedTime(Pw::getTime());
             Wekit::load('SRV:log.PwLogLogin')->addLog($dm);
             return $this->updateTryLog($info['uid'], $ip, 'pwd');
         case -3:
             //用户安全问题错误
             Wind::import('SRV:log.PwLogLogin');
             Wind::import('SRV:log.dm.PwLogLoginDm');
             $dm = new PwLogLoginDm($info['uid']);
             $dm->setUsername($info['username'])->setIp($ip)->setCreatedTime(Pw::getTime())->setTypeid(PwLogLogin::ERROR_SAFEQ);
             Wekit::load('SRV:log.PwLogLogin')->addLog($dm);
             return $this->updateTryLog($info['uid'], $ip, 'question');
     }
     if (($result = $this->runWithVerified('afterLogin', $info)) instanceof PwError) {
         return $result;
     }
     return $info;
 }
Example #3
0
 /**
  * 检查验证结果
  * @param int $status
  * @param array $info
  * @return array|PwError
  */
 protected function checkVerifyResult($status, $info)
 {
     switch ($status) {
         case 1:
             //用户信息正常
             if (true !== ($r = $this->allowTryAgain($info['uid'], $ip))) {
                 return $r;
             }
             break;
             //return array(1, $r[1]);
         //return array(1, $r[1]);
         case -13:
             //用户密码错误
             Wind::import('SRV:log.PwLogLogin');
             Wind::import('SRV:log.dm.PwLogLoginDm');
             $dm = new PwLogLoginDm($info['uid']);
             $dm->setUsername($info['username'])->setTypeid(PwLogLogin::ERROR_PWD)->setIp($ip)->setCreatedTime(Pw::getTime());
             Wekit::load('SRV:log.PwLogLogin')->addLog($dm);
             return $this->updateTryRecord($info['uid'], $ip, 'pwd');
             //return array(-2, $r[1]);
         //return array(-2, $r[1]);
         case -20:
             //用户安全问题错误
             Wind::import('SRV:log.PwLogLogin');
             Wind::import('SRV:log.dm.PwLogLoginDm');
             $dm = new PwLogLoginDm($info['uid']);
             $dm->setUsername($info['username'])->setIp($ip)->setCreatedTime(Pw::getTime())->setTypeid(PwLogLogin::ERROR_SAFEQ);
             Wekit::load('SRV:log.PwLogLogin')->addLog($dm);
             return $this->updateTryRecord($info['uid'], $ip, 'question');
             //return array(-3, $r[1]);
         //return array(-3, $r[1]);
         case -14:
             //用户不存在
         //用户不存在
         default:
             return new PwError('USER:user.error.-14');
             //return array(-1, array());
     }
     return $info;
 }