11ya/actual-user-bundle
Symfony bundle that keeps user roles and data up to date without forcing re-login. Add ActualUserInterface to your User, switch security to the provided custom user provider, and roles refresh automatically on subsequent requests.
auth() helper, Illuminate\Auth\AuthManager) differs fundamentally in design and implementation.auth()->user()->setRoles() or event-based role updates (e.g., Authenticated event listeners). However, Laravel’s session/guard system handles role persistence differently (via User model attributes or database).Authenticating, Authenticated) or model observers for role updates, reducing the need for a dedicated bundle.SecurityContext vs. Laravel’s Guard/UserProvider architecture.SecurityBundle-like dependency injection system for role providers.Authenticating event to update roles dynamically.app/Http/Middleware/RefreshRoles.php).eloquent.updated events on the User model.ActualUserInterface would require rewriting for Laravel’s User model (e.g., implementing setRoles() manually).security.yml) has no Laravel equivalent (uses config/auth.php + UserProvider).AppKernel, Symfony DI container).spatie/laravel-permission for role management)?auth()->user()->refresh() or Authenticating events don’t?User::update())?HasDynamicRoles) suffice?laravel-role-permission)?SecurityBundle, SecurityContext, and UserProviderInterface.Illuminate\Auth\AuthManager, UserProvider, and session-based guards.ActualUserInterface and provider service would need complete rewrites for Laravel’s User model and Guard system.role_id or JSON roles array).spatie/laravel-permission, nWidart/laravel-roles).users table with role_id or roles JSON column.eloquent.updated: User or auth.authenticated to refresh roles.// app/Listeners/RefreshUserRoles.php
public function handle($event) {
$user = $event->user;
$user->refreshRolesFromDatabase(); // Custom logic
}
// app/Http/Middleware/RefreshRoles.php
public function handle($request, Closure $next) {
if (auth()->check() && auth()->user()->rolesNeedRefresh()) {
auth()->user()->refreshRoles();
}
return $next($request);
}
save():
// app/Models/User.php
protected static function boot() {
parent::boot();
static::updated(function ($user) {
$user->refreshRoles();
});
}
ActualUserBundle—Laravel’s ecosystem provides better-native solutions.SecurityBundle dependency.SecurityContext or UserProviderInterface in the same form.refreshRoles() method to the User model.Authenticating event").spatie/laravel-permission or similar packages reduces maintenance burden (active community, updates).SecurityContext) would confuse Laravel developers.spatie/laravel-permission have active communities and Stack Overflow presence.shouldRefresh() checks).SecurityContext is not a concern in Laravel.SecurityBundle is irrelevant to Laravel’s auth system.eloquent.updated events or Authenticating listeners are well-documented and require minimal setup.// 5 minutes to implement vs. weeks to adapt Symfony bundle
How can I help you explore Laravel packages today?