package utils import ( "github.com/golang-jwt/jwt/v5" "gorm.io/gorm" "net/http" "sonarqube-badge/config" "sonarqube-badge/store" ) func VerifyUser(w http.ResponseWriter, r *http.Request) (*gorm.DB, config.Config, *store.User, bool) { ctx := r.Context() cfg := ctx.Value("config").(config.Config) db := ctx.Value("db").(*gorm.DB) token, err := GetToken(r) if err != nil { w.WriteHeader(http.StatusForbidden) return nil, cfg, nil, true } email := token.Claims.(jwt.MapClaims)["email"].(string) user := GetUser(ctx, email) if user == nil { w.WriteHeader(http.StatusNotFound) return nil, cfg, nil, true } return db, cfg, user, false }