Skip to content

Commit

Permalink
#15 create passport trait
Browse files Browse the repository at this point in the history
  • Loading branch information
SyntaxErrorLineNULL committed Aug 9, 2021
1 parent 1ada7eb commit ed6de46
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/Core/Authentication/PassportTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
/**
* Author: SyntaxErrorLineNULL.
*/

declare(strict_types=1);

namespace SELN\App\Core\Authentication;

use Psr\Http\Message\ServerRequestInterface;
use SELN\App\Core\Authentication\Passport\Passport;

trait PassportTrait
{
public function authentication(ServerRequestInterface $request): Passport
{
return $request->getAttribute(Passport::ATTRIBUTE);
}

public function checkAuth(ServerRequestInterface $request): string|int
{
$identification = $this->authentication($request);
return $identification->getAuthId();
}
}

0 comments on commit ed6de46

Please sign in to comment.