package middlewares import ( "bssapp-backend/auth" "bssapp-backend/ctxkeys" "context" ) func getClaims(ctx context.Context) *auth.Claims { if v := ctx.Value(ctxkeys.UserContextKey); v != nil { if c, ok := v.(*auth.Claims); ok { return c } } return nil } // -------------------------------------------------- // 🔐 SESSION // -------------------------------------------------- func GetSessionID(ctx context.Context) string { if c := getClaims(ctx); c != nil { return c.SessionID } return "" } // -------------------------------------------------- // 🔑 USER ID (mk_dfusr.id) // -------------------------------------------------- func GetUserID(ctx context.Context) int64 { if c := getClaims(ctx); c != nil { return c.ID } return 0 } // -------------------------------------------------- // 👤 USERNAME // -------------------------------------------------- func GetUsername(ctx context.Context) string { if c := getClaims(ctx); c != nil { return c.Username } return "" } // -------------------------------------------------- // 🧩 ROLE // -------------------------------------------------- func GetRoleCode(ctx context.Context) string { if c := getClaims(ctx); c != nil && c.RoleCode != "" { return c.RoleCode } return "public" }