| Total Complexity | 4 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 24 | class Passport extends Authorization |
||
| 25 | { |
||
| 26 | /** |
||
| 27 | * Illuminate authentication manager. |
||
| 28 | * |
||
| 29 | * @var \Illuminate\Contracts\Auth\Guard |
||
| 30 | */ |
||
| 31 | protected $auth; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * The guard driver name. |
||
| 35 | * |
||
| 36 | * @var string |
||
| 37 | */ |
||
| 38 | protected $guard = 'api'; |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Create a new basic provider instance. |
||
| 42 | * |
||
| 43 | * @param \Illuminate\Auth\AuthManager $auth AuthManager |
||
| 44 | */ |
||
| 45 | public function __construct(AuthManager $auth) |
||
| 46 | { |
||
| 47 | $this->auth = $auth->guard($this->guard); |
||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Authenticate request with a Illuminate Guard. |
||
| 52 | * |
||
| 53 | * @param \Illuminate\Http\Request $request Request |
||
| 54 | * @param \Dingo\Api\Routing\Route $route Route |
||
| 55 | * |
||
| 56 | * @return mixed |
||
| 57 | */ |
||
| 58 | public function authenticate(Request $request, Route $route) |
||
| 59 | { |
||
| 60 | if (!$user = $this->auth->user()) { |
||
| 61 | throw new UnauthorizedHttpException(null, 'Unauthenticated.'); |
||
| 62 | } |
||
| 63 | |||
| 64 | return $user; |
||
| 65 | } |
||
| 66 | |||
| 67 | /** |
||
| 68 | * Get the providers authorization method. |
||
| 69 | * |
||
| 70 | * @return string |
||
| 71 | */ |
||
| 72 | public function getAuthorizationMethod() |
||
| 75 | } |
||
| 76 | } |
||
| 77 |