Skip to content

feat: actor-based multi-session authentication#228

Merged
techmahedy merged 2 commits intodoppar:3.xfrom
techmahedy:techmahedy-3.x
Mar 14, 2026
Merged

feat: actor-based multi-session authentication#228
techmahedy merged 2 commits intodoppar:3.xfrom
techmahedy:techmahedy-3.x

Conversation

@techmahedy
Copy link
Member

Introduces actor-based authentication to support multiple independent session contexts (e.g. web, admin) within the same application.


Login

Before

Auth::try($request->passed());

After

auth('admin')->try($request->passed());
Auth::actor('admin')->try($request->passed());

Fetch authenticated user

Before

Auth::user();
auth()->user();

After

auth('admin')->user();
Auth::actor('admin')->user();
auth('admin')->user()->name;
Auth::actor('admin')->user()->name;

config/auth.php

Before

return [
    'model' => App\Models\User::class,
];

After

return [
    'default' => 'web',

    'actors' => [
        'web' => [
            'model'       => App\Models\User::class,
            'session_key' => 'user',
        ],
        'admin' => [
            'model'       => App\Models\Admin::class,
            'session_key' => 'admin',
        ],
    ],
];

Authenticate middleware

Before

if (Auth::check()) {
    return $next($request);
}

After

foreach (config('auth.actors') as $actor => $_) {
    if (Auth::actor($actor)->check()) {
        return $next($request);
    }
}

GuestMiddleware

Before

if (Auth::check()) {
    return redirect('/home');
}

After

foreach (config('auth.actors') as $actor => $_) {
    if (Auth::actor($actor)->check()) {
        return redirect('/home');
    }
}

@techmahedy techmahedy requested a review from rrr63 March 13, 2026 16:52
@techmahedy techmahedy added the feat new feature label Mar 13, 2026
@techmahedy
Copy link
Member Author

@rrr63 hope you will check it carefully, before checking, update middleware and config as described, from my end, it is good to go.

@techmahedy techmahedy self-assigned this Mar 14, 2026
@techmahedy techmahedy merged commit e0f1cb3 into doppar:3.x Mar 14, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant