1
0
mirror of https://github.com/flarum/core.git synced 2025-08-05 07:57:46 +02:00

Fix inconsistent status codes

HTTP 401 should be used when logging in (i.e. authenticating) would make
a difference; HTTP 403 is reserved for requests that fail because the
already authenticated user is not authorized (i.e. lacking permissions)
to do something.
This commit is contained in:
Franz Liedke
2019-08-20 07:19:55 +02:00
committed by Daniël Klabbers
parent 53c728b184
commit f7222d7e20
10 changed files with 53 additions and 24 deletions

View File

@@ -63,7 +63,7 @@ class AuthenticateWithApiKeyTest extends TestCase
$response = $api->send(CreateGroupController::class, new Guest);
$this->assertEquals(403, $response->getStatusCode());
$this->assertEquals(401, $response->getStatusCode());
}
/**

View File

@@ -78,7 +78,7 @@ class CreateGroupControllerTest extends ApiControllerTestCase
/**
* @test
*/
public function unauthorized_user_cannot_create_group()
public function normal_user_cannot_create_group()
{
$this->actor = User::find(2);

View File

@@ -34,7 +34,7 @@ class ListNotificationsControllerTest extends ApiControllerTestCase
{
$response = $this->callWith();
$this->assertEquals(403, $response->getStatusCode());
$this->assertEquals(401, $response->getStatusCode());
}
/**

View File

@@ -40,7 +40,7 @@ class ListUsersControllerTest extends ApiControllerTestCase
{
$response = $this->callWith();
$this->assertEquals(403, $response->getStatusCode());
$this->assertEquals(401, $response->getStatusCode());
}
/**