Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authcode model should be used for persisting new authcode #808

Merged
merged 2 commits into from
Aug 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/AuthCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ class AuthCode extends Model
'expires_at',
];

/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = false;

/**
* Get the client that owns the authentication code.
*
Expand Down
7 changes: 5 additions & 2 deletions src/Bridge/AuthCodeRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Laravel\Passport\Bridge;

use Laravel\Passport\Passport;
use Illuminate\Database\Connection;
use League\OAuth2\Server\Entities\AuthCodeEntityInterface;
use League\OAuth2\Server\Repositories\AuthCodeRepositoryInterface;
Expand Down Expand Up @@ -41,14 +42,16 @@ public function getNewAuthCode()
*/
public function persistNewAuthCode(AuthCodeEntityInterface $authCodeEntity)
{
$this->database->table('oauth_auth_codes')->insert([
$attributes = [
'id' => $authCodeEntity->getIdentifier(),
'user_id' => $authCodeEntity->getUserIdentifier(),
'client_id' => $authCodeEntity->getClient()->getIdentifier(),
'scopes' => $this->formatScopesForStorage($authCodeEntity->getScopes()),
'revoked' => false,
'expires_at' => $authCodeEntity->getExpiryDateTime(),
]);
];

Passport::authCode()->setRawAttributes($attributes)->save();
}

/**
Expand Down