/** * Execute the console command. * * @return mixed */ public function handle() { $hash = $this->argument('hash'); $key = $this->argument('key'); try { \Authorizer::validateAccessToken(false, $key); $resourceOwnerId = \Authorizer::getResourceOwnerId(); $user = \Authorization::loginUsingId($resourceOwnerId); if ($user->hash === $hash) { $this->info('Authenticated'); } else { throw new \Exception('User hash does not match auth key'); } } catch (OAuthException $e) { throw new \Exception('Authentication error: invalid authentication key'); } }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $resourceOwnerId = Authorizer::getResourceOwnerId(); $user = \Authorization::loginUsingId($resourceOwnerId); return $response = $next($request); }