Esempio n. 1
0
 /**
  * 执行查询用户设备信息
  *
  * @return mixed $value 返回最终需要执行完的结果
  * @throws
  * @since 1.0.7
  */
 private function judgeDevice()
 {
     $deviceType = $_REQUEST['device_type'];
     //这里对iPhone/iPad做了一个补偿操作,此前的绑定设备类型出了错误。因为类型是6而不是5
     if (MiniHttp::isiPhone()) {
         $deviceType = 6;
     }
     $deviceName = urldecode($_REQUEST['device_name']);
     $deviceInfo = $_REQUEST['device_info'];
     if (!empty($deviceType) && !empty($deviceName) && !empty($deviceInfo)) {
     } else {
         # 当用户传递过来的设备信息都为空时,表示为三方开发者
         if (empty($deviceType) && empty($deviceName) && empty($deviceInfo)) {
             $deviceType = 10;
             $deviceName = "第三方用户";
             $deviceInfo = "第三方设备";
         } else {
             throw new MAuthorizationException("param_is_null", MConst::HTTP_CODE_400);
         }
     }
     //如被锁定,且是网页端则不进行登录。
     $userName = $_REQUEST['username'];
     if (empty($userName)) {
         $userName = $_POST['username'];
     }
     $name = urldecode($userName);
     $isLock = MiniUser::getInstance()->isLock($name);
     $user = false;
     if (!($isLock && MiniHttp::clientIsBrowser())) {
         $user = self::searchUser();
     }
     if ($user === false) {
         //如果用户在非锁定状态,则错误数+1
         if (!$isLock) {
             MiniUser::getInstance()->setPasswordError($name);
         }
         return false;
     } else {
         //如果用户登录正确,则把密码错误次数清空
         MiniUser::getInstance()->cleanPasswordError($name);
     }
     if (!$user["user_status"]) {
         throw new MAuthorizationException("User has disabled.", MConst::HTTP_CODE_407);
     }
     //对设备进行检测
     $device = DeviceManager::getDevice($user["id"], $deviceType, $deviceName, $deviceInfo);
     return $device;
 }
Esempio n. 2
0
 /**
  * 获得当前登录的设备
  * @param $user
  * @return null
  */
 private function getCurrentDevice($user)
 {
     $deviceType = 1;
     if (MiniHttp::isPCClient()) {
         if (MiniHttp::isWindowsOS()) {
             $deviceType = 2;
             //Windows 客户端
         } else {
             if (MiniHttp::isMacOS()) {
                 $deviceType = 3;
                 //Mac 客户端
             } else {
                 $deviceType = 5;
                 //Linux 客户端
             }
         }
     }
     //对设备进行检测
     if ($deviceType == 1) {
         $device = DeviceManager::getDevice($user["id"], MConst::DEVICE_WEB, "web", $_SERVER['HTTP_USER_AGENT']);
     } else {
         $device = MiniUserDevice::getInstance()->getFirstByDeviceTypeAndDeviceName($user["id"], $deviceType);
     }
     return $device;
 }