Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Preferences/Preferences.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function all()
{
$this->resetState();

if (auth()->check()) {
if (User::current()) {
$this
->mergeDottedUserPreferences()
->mergeDottedRolePreferences();
Expand Down
12 changes: 12 additions & 0 deletions tests/CP/AuthRedirectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Statamic\Exceptions\AuthorizationException;
use Statamic\Facades\User;
use Statamic\Statamic;
use Tests\Auth\Eloquent\User as EloquentUser;
use Tests\FakesRoles;
use Tests\PreventSavingStacheItemsToDisk;
use Tests\TestCase;
Expand Down Expand Up @@ -94,4 +95,15 @@ public function it_redirects_to_unauthorized_view_if_there_would_be_a_redirect_l
->assertRedirect(cp_route('unauthorized'))
->assertSessionHas(['error' => 'Unauthorized.']);
}

#[Test]
public function it_redirects_to_login_when_authenticated_user_is_not_a_statamic_user()
{
$nonStatamicUser = EloquentUser::make();

$this
->actingAs($nonStatamicUser)
->get('/cp')
->assertRedirect(cp_route('login'));
}
}
Loading