create static method
Creates a new web authentication middleware
redirectTo - Where to redirect unauthenticated users (default: '/login')
except - Routes to exclude from authentication check
guard - Auth guard to use (default: 'web')
Implementation
static Middleware create({
String redirectTo = '/login',
List<String> except = const [],
String guard = 'web',
}) {
return Middleware(
(Request request, ResponseContract response, NextFunction next) async {
// Check if route is excluded
if (_isExcluded(request.path, except)) {
return next();
}
// For web guard, check session-based authentication
await _handleWebAuth(request, response, next, guard, redirectTo);
},
priority: MiddlewarePriority.auth,
name: 'web-auth',
);
}