/** * Stores user identity * * @param \MongoId $userId * @param \Vegas\Security\OAuth\Identity $oAuthIdentity * @return bool */ public static function addUserIdentity(\MongoId $userId, \Vegas\Security\OAuth\Identity $oAuthIdentity) { $identity = new Identity(); $identity->writeAttribute('user_id', $userId); $identity->writeAttribute('id', $oAuthIdentity->getId()); $identity->writeAttribute('email', $oAuthIdentity->getEmail()); $identity->writeAttribute('service', $oAuthIdentity->getService()); return $identity->save(); }
/** * Adds oAuth identity for authenticated user * * @param AuthIdentity $authIdentity * @param Identity $oauthIdentity */ private function afterAuthentication(AuthIdentity $authIdentity, OAuthIdentity $oauthIdentity) { \Oauth\Models\Identity::addUserIdentity($authIdentity->getId(), $oauthIdentity); }