Пример #1
0
 public function login($token)
 {
     $this->token = $token;
     $userinfo = $this->getUserInfo();
     $userinfo['username'] = $userinfo['screen_name'];
     $userinfo['avatar'] = $userinfo['profile_image_url'];
     $user = new OAuthUser('weibo', $this->openid);
     $user->setinfo($userinfo);
     $this->setUser($user);
     return true;
 }
Пример #2
0
 public function login($token)
 {
     $this->token = $token;
     if (!$this->getOpenId()) {
         return false;
     }
     $userinfo = $this->getUserInfo();
     $userinfo['username'] = $userinfo['nickname'];
     $userinfo['avatar'] = $userinfo['figureurl_qq_1'];
     $user = new OAuthUser('qq', $this->openid);
     $user->setinfo($userinfo);
     $this->setUser($user);
     return true;
 }
Пример #3
0
 /**
  *
  **/
 public function authorize_action()
 {
     global $user, $auth;
     $auth->login_if($user->id == 'nobody');
     $user_id = OAuthUser::getMappedId($user->id);
     // Fetch the oauth store and the oauth server.
     $store = OAuthStore::instance();
     $server = new OAuthServer();
     try {
         // Check if there is a valid request token in the current request
         // Returns an array with the consumer key, consumer secret, token, token secret and token type.
         $rs = $server->authorizeVerify();
         if (isset($_POST['allow'])) {
             // See if the user clicked the 'allow' submit button (or whatever you choose)
             $authorized = array_key_exists('allow', $_POST);
             // Set the request token to be authorized or not authorized
             // When there was a oauth_callback then this will redirect to the consumer
             $server->authorizeFinish($authorized, $user_id);
             // No oauth_callback, show the user the result of the authorization
             // ** your code here **
             PageLayout::postMessage(Messagebox::success(_('Sie haben der Applikation Zugriff auf Ihre Daten gewährt.')));
             $this->redirect('user#' . $rs['consumer_key']);
         }
     } catch (OAuthException $e) {
         // No token to be verified in the request, show a page where the user can enter the token to be verified
         // **your code here**
         die('invalid');
     }
     PageLayout::disableHeader();
     $this->set_layout($GLOBALS['template_factory']->open('layouts/base_without_infobox'));
     $this->rs = $rs;
 }
 /**
  * Fetch a list of users based on the value of a given column.  Returns empty array if no match is found.
  *
  * @param value $value The value to find. (defaults to null, which means return all records in the table)
  * @param string $name The name of the column to match (defaults to null)
  * @return array An array of User objects
  */
 public static function fetchAll($value = null, $name = null)
 {
     if (!$value || !$name) {
         $result = OAuthUser::all();
     } else {
         $result = OAuthUser::where($name, $value)->get();
     }
     $users = [];
     foreach ($result as $user) {
         $users[$user->id] = $user;
     }
     return $users;
 }
 protected function standardAttributes()
 {
     return array_merge(parent::standardAttributes(), array('twitter_userID'));
 }
 /**
  * storeOauth - Save the oauth data to the datbase
  * @param type $userid
  */
 public function storeOAuth($userid)
 {
     $this->_user_profile = $_SESSION['userfrosting']['oauth_details'];
     $user_details = $this->transform($this->_user_profile);
     $user_details['user_id'] = $userid;
     $user_details['provider'] = strtolower($this->_provider_name);
     // check to see if we have a record with this UID
     $cur_oauth_user = OAuthUserLoader::fetch($user_details['uid'], 'uid');
     //logarr($user_details,"Line 82 user id is $userid and uid is ".$user_details['uid']);
     //logarr($cur_oauth_user,"Line 84");
     // if we find a record with the UID then, update the record
     if (is_object($cur_oauth_user)) {
         foreach ($user_details as $usrkey => $usrdata) {
             // do not update the UID or user_id fields
             if ($usrkey != 'user_id' && $usrkey != 'uid') {
                 $cur_oauth_user->{$usrkey} = $usrdata;
             }
         }
         $oauth_user = $cur_oauth_user;
     } else {
         $oauth_user = new OAuthUser($user_details);
     }
     //logarr($user_details,"Line 99 user id $userid");
     //logarr($oauth_user,"Line 99 user id oauth_user");
     // Save to database
     $oauth_user->save();
 }
Пример #7
0
 /**
  *
  **/
 public function revoke_action($consumer_key)
 {
     OAuthUser::revokeToken($GLOBALS['user']->id, $consumer_key);
     PageLayout::postMessage(MessageBox::success(_('Der Applikation wurde der Zugriff auf Ihre Daten untersagt.')));
     $this->redirect('user/index');
 }