Skip to content

Commit

Permalink
change user is not loggedin exception name
Browse files Browse the repository at this point in the history
  • Loading branch information
wellingguzman committed Apr 1, 2018
1 parent 5bb071f commit d6a0313
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Directus\Application\Http\Request;
use Directus\Application\Http\Response;
use Directus\Authentication\Exception\InvalidUserCredentialsException;
use Directus\Authentication\Exception\UserIsNotLoggedInException;
use Directus\Authentication\Exception\UserNotAuthenticatedException;
use Directus\Authentication\User\User;
use Directus\Authentication\User\UserInterface;
use Directus\Database\TableGateway\BaseTableGateway;
Expand All @@ -27,7 +27,7 @@ class AuthenticationMiddleware extends AbstractMiddleware
* @return Response
*
* @throws InvalidUserCredentialsException
* @throws UserIsNotLoggedInException
* @throws UserNotAuthenticatedException
*/
public function __invoke(Request $request, Response $response, callable $next)
{
Expand Down Expand Up @@ -62,7 +62,7 @@ public function __invoke(Request $request, Response $response, callable $next)
$authenticated = $this->authenticate($request);
$publicGroupId = $this->getPublicGroupId();
if (!$authenticated && !$publicGroupId) {
throw new UserIsNotLoggedInException();
throw new UserNotAuthenticatedException();
}

// =============================================================================
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Directus\Authentication\Exception;

use Directus\Exception\Exception;

class UserNotAuthenticatedException extends Exception
{
const ERROR_CODE = 108;

public function __construct($message = 'User not authenticated')
{
parent::__construct($message, static::ERROR_CODE);
}
}
4 changes: 2 additions & 2 deletions tests/api/Authentication/ProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ public function testSecretKey()
}

/**
* @expectedException \Directus\Authentication\Exception\UserIsNotLoggedInException
* @expectedException \Directus\Authentication\Exception\UserNotAuthenticatedException
*/
public function testAuthenticationEnforcement()
{
$this->provider->getUserAttributes();
}

/**
* @expectedException \Directus\Authentication\Exception\UserIsNotLoggedInException
* @expectedException \Directus\Authentication\Exception\UserNotAuthenticatedException
*/
public function testAuthenticationEnforcement2()
{
Expand Down

0 comments on commit d6a0313

Please sign in to comment.