public function AppLogout($user) { FuegoLog::getLog()->LogInfo("APP logout..."); $condition['user_id'] = $user['user_id']; $tokenDao = MispDaoContext::Token(); $result = MispCommonService::Delete($tokenDao, $condition); FuegoLog::getLog()->LogInfo("Delete token success."); return MispErrorCode::SUCCESS; }
public function DoAuth() { $this->LogInfo("User login validator.DoAuth..."); $req = $this->GetReqObj(); $condition['token_name'] = $req->token; $tokenDao = MispDaoContext::Token(); $tokenCount = $tokenDao->where($condition)->count(); if (0 == $tokenCount) { $this->LogWarn("DoAuth failed, user login invalid."); $this->errorCode = MispErrorCode::ERROR_LOGIN_INVALID; $this->ReturnJson(); } $this->LogInfo("DoAuth success."); }
public function Login() { $Req = $this->GetReqObj(); $req = $this->GetCommonData(); $reqType = $this->GetReqType(); $this->LogInfo("User login, Client type is " . $reqType); $user['user_name'] = $req->user_name; $user['password'] = $req->password; if ($reqType == ClientTypeEnum::IOS || $reqType == ClientTypeEnum::ANDROID) { //APP客户端登陆验证 $data = null; $user['company_id'] = $Req->app_id; $this->LogInfo("Login client type is " . $reqType . ",company_id is " . $Req->app_id); //验证用户与登录密码 try { $orignalUser = MispCommonUserService::LoginValidate($user); } catch (FuegoException $e) { $this->errorCode = $e->getCode(); return $this->ReturnJson(); } //获取用户APP登录权限 $privilegeResult = MispCommonDataService::GetRolePrivilege($orignalUser, PrivilegeEnum::ACCESS_TYPE_LOGIN, PrivilegeEnum::ACCESS_VALUE_APP_LOGIN); if (false == $privilegeResult) { //用户不存在APP登录权限 $this->LogWarn("Get role privilege failed.The user don't have APP login privilege, login failed."); $this->errorCode = MispErrorCode::USERNAME_OR_PASSWORD_WRONG; return $this->ReturnJson(); } else { //获取登录权限成功 $this->LogInfo("Get user login privilege success. The user have APP login privilege."); //判断是否已经在其他设备登录 $condition['user_id'] = $orignalUser['user_id']; $tokenDao = MispDaoContext::Token(); $tokenCount = $tokenDao->where($condition)->count(); $this->LogInfo("Token count is " . $tokenCount); if ($tokenCount > 0) { //用户已在其他设备登录,删除已有token $this->LogInfo("The user has login in other device, user name is " . $orignalUser['user_name']); try { $result = MispCommonService::Delete($tokenDao, $condition); $this->LogInfo("Delete orginal token success."); } catch (FuegoException $e) { $this->LogWarn("Delete orginal token failed."); $this->LogWarn("Customer APPLogin failed"); $this->errorCode = MispErrorCode::ERROR_LOGIN_FAILED; $this->ReturnJson(); return; } } //APP登录成功 $data = MispServiceContext::UserManage()->AppLogin($orignalUser); } $this->ReturnJson($data); } if ($reqType == ClientTypeEnum::WEB) { //WEB端登陆验证 //验证用户与登录密码 try { $orignalUser = MispCommonUserService::LoginValidate($user); } catch (FuegoException $e) { $this->errorCode = $e->getCode(); return $this->ReturnJson(); } $privilegeResult = MispCommonDataService::GetRolePrivilege($orignalUser, PrivilegeEnum::ACCESS_TYPE_LOGIN, PrivilegeEnum::ACCESS_VALUE_WEB_LOGIN); if (false == $privilegeResult) { //用户不存在WEB登录权限 $this->LogWarn("Get role privilege failed. The user don't have WEB login privilege, login failed."); $this->errorCode = MispErrorCode::USERNAME_OR_PASSWORD_WRONG; } else { //WEB登录成功 $this->LogInfo("Get user login privilege success. The user have WEB login privilege."); $this->errorCode = MispServiceContext::UserManage()->WebLogin($orignalUser); } } $this->ReturnJson(); }