package middleware import ( "net/http" "os" "strings" "go.laravel.com/web" "app/models" ) type Operator struct{} func (Operator) Handle(request *web.Request, next web.Next) *web.Response { user := models.CurrentUser(request) if user == nil { return web.Abort(http.StatusUnauthorized) } for _, allowed := range strings.Split(os.Getenv("OPSPROOF_OPERATOR_EMAILS"), ",") { if strings.EqualFold(strings.TrimSpace(allowed), user.Email) { return next(request) } } return web.Abort(http.StatusForbidden) }