public static function getStoken() { if (!($sToken = Pix_Session::get('sToken'))) { $sToken = crc32(uniqid()); Pix_Session::set('sToken', $sToken); } return $sToken; }
public function googledoneAction() { $consumer = $this->getGoogleConsumer(); $return_to = 'http://' . $_SERVER['HTTP_HOST'] . '/login/googledone'; $response = $consumer->complete($return_to); if ($response->status == Auth_OpenID_CANCEL) { return $this->alert('取消登入', '/'); } if ($response->status == Auth_OpenID_FAILURE) { return $this->alert('登入失敗: ' . $response->message, '/'); } $ax = new Auth_OpenID_AX_FetchResponse(); $obj = $ax->fromSuccessResponse($response); $email = $obj->data['http://axschema.org/contact/email'][0]; if (!($user = User::search(array('user_name' => 'google://' . $email))->first())) { $user = User::insert(array('user_name' => 'google://' . $email)); } Pix_Session::set('user_id', $user->user_id); return $this->redirect('/'); }