package firebase

import (
	"context"
	"fmt"

	"firebase.google.com/go/v4/auth"
)

// SetUserDisabled updates the Firebase user record's disabled flag.
func SetUserDisabled(ctx context.Context, uid string, disabled bool) error {
	if authClient == nil {
		return fmt.Errorf("firebase auth not initialized") //nolint:err113
	}
	if uid == "" {
		return nil
	}

	params := (&auth.UserToUpdate{}).Disabled(disabled)
	_, err := authClient.UpdateUser(ctx, uid, params)
	return err
}
