Skip to content

Commit

Permalink
Fixed style and updated unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel committed Jul 31, 2018
1 parent 790ac58 commit 99dfe3b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/Http/Middleware/MultiAuthenticate.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ public function __construct(
public function handle($request, Closure $next, ...$guards)
{
// If don't has any guard follow the flow
// stop laravel from checking for a token if session is not set
if (empty($guards)) {
$this->authenticate($guards);

// Stop laravel from checking for a token if session is not set
return $next($request);
}

Expand Down Expand Up @@ -114,7 +115,7 @@ public function canBeAuthenticated(Authenticatable $user, $guards)
*
* @param \SMartins\PassportMultiauth\Provider $token
* @param array $guards
* @return mixed
* @return void
*
* @throws \Illuminate\Auth\AuthenticationException
*/
Expand All @@ -125,6 +126,6 @@ public function authenticateTokenGuard(Token $token, $guards)
// use only guard associated to access token provider
$authGuards = $providers->has($token->provider) ? [$providers->get($token->provider)] : [];

return $this->authenticate($authGuards);
$this->authenticate($authGuards);
}
}
3 changes: 2 additions & 1 deletion tests/Unit/MultiAuthenticateMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ public function testTryAuthWithoutGuards()
$request = $this->createRequest();

$middleware = new MultiAuthenticate($resourceServer, $repository, $this->auth);
$middleware->handle($request, function () {
$response = $middleware->handle($request, function () {
return 'response';
});
$this->assertEquals('response', $response);
}

public function testTryAuthWithoutAccessTokenId()
Expand Down

0 comments on commit 99dfe3b

Please sign in to comment.