Skip to content

Impersonating a user only works via Nova 4 Login route when using with Jetstream #3894

@RhysLees

Description

@RhysLees

Description:

Impersonating a user only works on routes for Jetstream when you log in via the Nova Login route. logging in via jetstreams auth route then impersonating causes you to be logged out of the session.

image
image
image

Detailed steps to reproduce the issue on a fresh Nova installation:

  1. clone reproduction repo
  2. migrate DB (migrating also creates 2 users and an admin)
  3. login with email admin@admin.co.uk pass admin123 via jetstream login /login
  4. goto nova user page and impersonate user 1 or user 2, this will redirect you to /
  5. click dashboard in the top right and you will be logged out
  6. now login via nova login route /nova/login
  7. repeat steps 4 and 5 and you will not be logged out and impersonation works as intended.

The only thing I how found that fixed this is to remove config('jetstream.auth_session'), from the middleware group

Not working:

Route::middleware([
    'auth:sanctum',
    config('jetstream.auth_session'),
    'verified'
])->group(function () {
    Route::get('/dashboard', function () {
        return view('dashboard');
    })->name('dashboard');
});

Working:

Route::middleware([
    'auth:sanctum',
    'verified'
])->group(function () {
    Route::get('/dashboard', function () {
        return view('dashboard');
    })->name('dashboard');
});

Removing this makes the application less secure so I'm not sure if there is a better solution to this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions