function personalLiAction() { $token1 = $this->get("token"); $request = $this->getRequest(); $userModel = new UserModel(); $userModel->logout(); if ('POST' == $request->getMethod()) { $mobile = trim($this->post()->get("mobile")); } $url = Common_Config::SSO_VERIFY_URL; $domainId = Common_Config::UDO_OP_DOMAINID; $token = "tokend86ef2e5-e43b-4077-aafd-f2d3290a9889NHL2GezC"; $secret = Common_Config::UDO_OP_SECRET_SERVER; $sign_raw = $domainId . $token . $secret; $sign = md5($sign_raw); $post_data = array("domainId" => $domainId, "token" => $token, "sign" => $sign); //print_r($post_data); $cl = new Common_Curl(); $array = $cl->request($url, $post_data); $uid = $array['id']; //print_r($uid); //print_r($this->uid); $cookie = new User_Cookie(Common_Config::SITE_DOMAIN, Common_Config::SECURE_KEY, Common_Config::SECURE_SIGN); $cookie->login($uid); //print_r($this->uid); /*print_r($_SESSION['uid']);*/ /*print_r($array);*/ // print_r($array); $entrances = $array['entrances']; //print_r($entrances); $this->displayJsonUdo(Common_Error::ERROR_SUCCESS, $entrances); }
public function authenticateUser(User $user) { $userCookie = new User_Cookie(App::$config['APP_SHORT_NAME'], App::$config['APP_SECRET_KEY']); // step 1: do we have a if ($userCookie->isReturningUser()) { try { $userFromCookie->retrieve(App::$config['DB'], $userCookie->id); if ($userCookie->authenticateUser($user)) { $user->setFields($userFromCookie->getData()); // tell the routing engine that the user // is logged in App::$conditions->loggedIn = true; return true; } } catch (Datastore_E_RetrieveFailed $e) { // user does not exist in the database // nuke the cookie $userCookie->forgetUser(); } } return false; }
/** * 退出登录 */ public function logout() { $cookie = new User_Cookie(Common_Config::SITE_DOMAIN, Common_Config::SECURE_KEY, Common_Config::SECURE_SIGN); return $cookie->logout(); }
/** * 验证token * @param string $token * @param int $uid * @param string $api * @return boolean */ public static function check($token, $uid, $api) { $cookie = new User_Cookie(Common_Config::SITE_DOMAIN, Common_Config::SECURE_KEY, Common_Config::SECURE_SIGN); $ssotoken = $cookie->gettoken(); return $token == $ssotoken; }