示例#1
0
 public function vertifyUserCertificate($userId, $certificateToken, $app, $os, $v)
 {/*{{{*/
     $info = array();
     $info['isFollowupDoctor'] = 0;
     $user = DAL::get()->find('user', $userId);
     $info['freeFollowupUrl'] = "http://".URL_PREFIX."passport.haodf.com/user/mobileauthcheck?forward=".$user->space->getFreeFollowupFlowUrl();
     if($user->isNull())
     {
         $this->setErrorCode(107);
         return 0;
     }
     $certificateToken4Server = Datacrypt::getUserCertificate($userId);
     if($certificateToken4Server != $certificateToken)
     {
         $this->setErrorCode(501);
         return 0;
     }
     if($app == 'doctor' || $app == 'doctorhd')
     {
         MobileSettingClient::getInstance()->createWapSpace($user->space->id, $app, $os, $v);
         if($user->space->isDoctor() && $user->space->isOpenFollowup())
         {
             $info['isFollowupDoctor'] = 1; 
         }
     }
     $this->content = $info;
 }/*}}}*/
 public function doctorAuthUser($userName, $password, $os, $app, $v)
 {/*{{{*/
     $user = DAL::get()->find_by_name('user', $userName, true);
     if($user->isNull())
     {
         $this->setErrorCode(1221);
         return 0;
     }
     else
     {
         $user = UserClient::getInstance()->login($userName, $password);
         if($user->isNull())
         {
             $this->setErrorCode(1222);
             return 0;
         }
     }
    // if ($user->isNull())
    // {
    //     $this->setErrorCode(122);
    //     return 0;
    // }
     $space = $user->space;
     if(false == $space->isNull() && false == $space->isConfirmed())
     {
         $this->setErrorCode(330);
         return 0;
     }
     if(false == ($user->hasConfirmedSpace() && $user->space->isDoctor()))
     {
         $this->setErrorCode(323);
         return 0;
     }
     $freeFollowupUrl = "http://".URL_PREFIX."passport.haodf.com/user/mobileauthcheck?forward=".$space->getFreeFollowupFlowUrl();
     $this->content = array('_s' => self::doctorData($user, $os, $app, $v) , 'certificateToken' => Datacrypt::getUserCertificate($user->id), 'freeFollowupUrl'=>$freeFollowupUrl);
 }/*}}}*/
 public function test_vertifyUserCertificate()
 {/*{{{*/
     $userId = $this->getSpace()->user->id;
     $certificateToken = Datacrypt::getUserCertificate($this->getSpace()->user->id);
     $app = 'doctor';
     $os = 'ios';
     $v = '2.0.1';
     $this->data->vertifyUserCertificate($userId, $certificateToken, $app, $os, $v);
     $content = $this->getContent();
     $this->assertTrue(false == empty($content));
 }/*}}}*/