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
16 changes: 15 additions & 1 deletion app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Database\Factories\UserFactory;
use Filament\Models\Contracts\FilamentUser;
use Filament\Panel;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Attributes\Hidden;
use Illuminate\Database\Eloquent\Factories\HasFactory;
Expand All @@ -12,11 +14,23 @@

#[Fillable(['name', 'email', 'password'])]
#[Hidden(['password', 'remember_token'])]
class User extends Authenticatable
class User extends Authenticatable implements FilamentUser
{
/** @use HasFactory<UserFactory> */
use HasFactory, Notifiable;

/**
* Determine whether the user may access the given Filament panel.
*
* Super Stack ships without public registration, so every user in the
* database is one you created on purpose. Tighten this before you open
* sign-ups: check a role, an `is_admin` column, or the email domain.
*/
public function canAccessPanel(Panel $panel): bool
{
return true;
}

/**
* Get the attributes that should be cast.
*
Expand Down
12 changes: 10 additions & 2 deletions tests/Feature/AdminPanelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,16 @@
$response->assertOk();
});

test('authenticated users can access admin dashboard in local environment', function () {
config(['app.env' => 'local']);
test('authenticated users can access the admin dashboard', function () {
$user = User::factory()->create();

$response = $this->actingAs($user)->get('/admin');

$response->assertOk();
});

test('admin access does not depend on the local environment', function () {
config(['app.env' => 'production']);

$user = User::factory()->create();

Expand Down
Loading