public function handle(\Symfony\Component\HttpFoundation\Request $request, $type = self::MASTER_REQUEST, $catch = true) { if (!$request->headers->has('Authorization')) { $exception = new UnauthorizedException("No token provided."); $response = $exception->getJsonResponse(); return $response; } if ($request->headers->get('Authorization') === null) { $exception = new UnauthorizedException("No authorization header sent."); $response = $exception->getJsonResponse(); return $response; } $token = $this->auth->attempt(str_replace('Bearer ', '', $request->headers->get('Authorization'))); if (get_class($token) !== 'stdClass') { $exception = new UnauthorizedException($token->getMessage()); $response = $exception->getJsonResponse(); return $response; } }
public function getAuth() { return new Ok(['token' => $this->auth->createToken()]); }
/** * Gets an Auth model by parameters * * @param array $params * @return array */ public function getAuth($params) { return $this->auth->where($params)->first(); }