/** * Returns the authorize URL for a connection with the given * slug. Abstracts away the differences between OAuth1 and * OAuth2 for a uniform API. * * @param string $slug * @param string $callbackUri * @return string */ public function getAuthorizationUrl($slug, $callbackUri) { $provider = $this->make($slug, $callbackUri); // OAuth 1 is a three-legged authentication process // and thus we need to grab temporary credentials // first. if ($this->oauthVersion($provider) == 1) { $temporaryCredentials = $provider->getTemporaryCredentials(); $this->session->put($temporaryCredentials); return $provider->getAuthorizationUrl($temporaryCredentials); } return $provider->getAuthorizationUrl(); }
/** * {@inheritDoc} */ public function persist(PersistableInterface $persistable, $remember = false) { if ($this->single) { $this->flush($persistable); } $code = $persistable->generatePersistenceCode(); $this->session->put($code); if ($remember === true) { $this->cookie->put($code); } $persistence = $this->createModel(); $persistence->{$persistable->getPersistableKey()} = $persistable->getPersistableId(); $persistence->code = $code; return $persistence->save(); }
/** * Adds a new user persistence to the current session and attaches the user. * * @param User $persistable * @param bool $remember * @return bool */ public function persist(PersistableInterface $persistable, $remember = false) { try { if ($this->single) { $this->flush($persistable); } $code = $persistable->generatePersistenceCode(); $this->session->put($code); if ($remember === true) { $this->cookie->put($code); } $persistence = $this->create($persistable, $code); $entityManager = $this->getEntityManager(); $entityManager->persist($persistence); $entityManager->flush(); return true; } catch (\Exception $e) { return false; } }