package auth

import "context"

// Context keys for user information
type contextKey string

const (
	userInfoContextKey contextKey = "user_info"
)

// ContextWithUser adds user information to request context
func ContextWithUser(ctx context.Context, user *UserInfo) context.Context {
	return context.WithValue(ctx, userInfoContextKey, user)
}

// UserFromContext extracts user information from request context
func UserFromContext(ctx context.Context) (*UserInfo, bool) {
	user, ok := ctx.Value(userInfoContextKey).(*UserInfo)
	return user, ok
}

// UserIDFromContext extracts user ID from request context
func UserIDFromContext(ctx context.Context) string {
	if user, ok := UserFromContext(ctx); ok && user != nil {
		return user.ID
	}
	return "anonymous"
}
