/**
  * @inheritDoc
  */
 public function persistNewAuthCode(AuthCodeEntityInterface $authCodeEntity)
 {
     $scopes = [];
     foreach ($authCodeEntity->getScopes() as $scope) {
         $scopes[] = $scope->getIdentifier();
     }
     $this->conn->insert($this->getTableName(), ['id' => $authCodeEntity->getIdentifier(), 'scopes' => $scopes, 'expires_at' => $authCodeEntity->getExpiryDateTime(), 'user_id' => json_encode($authCodeEntity->getUserIdentifier()), 'client_id' => $authCodeEntity->getClient()->getIdentifier(), 'redirect_uri' => $authCodeEntity->getRedirectUri()], ['string', 'json_array', 'datetime', 'string', 'string', 'string']);
 }
Пример #2
0
 /**
  * Persists a new auth code to permanent storage.
  *
  * @param \League\OAuth2\Server\Entities\AuthCodeEntityInterface $authCodeEntity
  * @return mixed
  */
 public function persistNewAuthCode(AuthCodeEntityInterface $authCodeEntity)
 {
     $db = CommonModel::getDb();
     $transaction = $db->beginTransaction();
     try {
         $authCodeModel = new AuthCodesModel();
         $authCodeModel->id = $authCodeEntity->getIdentifier();
         $authCodeModel->expire_time = $authCodeEntity->getExpiryDateTime()->getTimestamp();
         $authCodeModel->user_id = (string) $authCodeEntity->getUserIdentifier();
         $authCodeModel->client_id = $authCodeEntity->getClient()->getIdentifier();
         if (!$authCodeModel->save()) {
             return false;
         }
         foreach ($authCodeEntity->getScopes() as $item) {
             $accessTokenScopesModel = new AuthCodeScopesModel();
             $accessTokenScopesModel->auth_code_id = $authCodeModel->id;
             $accessTokenScopesModel->scope_id = $item->getIdentifier();
             $accessTokenScopesModel->save();
         }
         $transaction->commit();
         return true;
     } catch (\Exception $e) {
         $transaction->rollBack();
         return false;
     }
 }
 /**
  * Persists a new auth code to permanent storage.
  *
  * @param \League\OAuth2\Server\Entities\AuthCodeEntityInterface $authCodeEntity
  */
 public function persistNewAuthCode(AuthCodeEntityInterface $authCodeEntity)
 {
     $newAuthCode = ['token' => $authCodeEntity->getIdentifier(), 'expire_time' => $authCodeEntity->getExpiryDateTime(), 'client_id' => $authCodeEntity->getClient()->getIdentifier()];
     if (!is_null($authCodeEntity->getUserIdentifier())) {
         $newAuthCode['user_id'] = $authCodeEntity->getUserIdentifier();
     }
     $authCodeModel = $this->modelResolver->getModel('AuthCodeModel');
     $authCodeModel::create($newAuthCode);
 }
 public function persistNewAuthCode(AuthCodeEntityInterface $entity)
 {
     $entity->save();
 }