/** * Create new view. * * @param Model_User $user * @param array $errors */ public function __construct(Model_User $user, array $errors = null) { parent::__construct(); $this->user = $user; $this->errors = $errors; $this->external = Model_User_External::factory()->find_by_user_id($this->user->id, 'facebook'); if ($this->external && $this->external->loaded()) { $this->consumer = new OAuth2_Consumer('facebook', $this->external->access_token()); } }
/** * Construct controller. * * @throws OAuth2_Exception_UnsupportedGrantType */ public function before() { parent::before(); $this->history = false; // See if we already have a token $provider = $this->request->param('provider'); if ($provider) { if (Visitor::$user && ($this->external = Model_User_External::factory()->find_by_user_id(Visitor::$user->id, $provider))) { // Access token should be available $this->consumer = new OAuth2_Consumer($provider, $this->external->loaded() ? $this->external->access_token() : false); } else { // No access token available $this->consumer = new OAuth2_Consumer($provider, false); } } }