You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

usertype.go 951B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright 2021 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package doctor
  4. import (
  5. "context"
  6. user_model "code.gitea.io/gitea/models/user"
  7. "code.gitea.io/gitea/modules/log"
  8. )
  9. func checkUserType(ctx context.Context, logger log.Logger, autofix bool) error {
  10. count, err := user_model.CountWrongUserType(ctx)
  11. if err != nil {
  12. logger.Critical("Error: %v whilst counting wrong user types")
  13. return err
  14. }
  15. if count > 0 {
  16. if autofix {
  17. if count, err = user_model.FixWrongUserType(ctx); err != nil {
  18. logger.Critical("Error: %v whilst fixing wrong user types")
  19. return err
  20. }
  21. logger.Info("%d users with wrong type fixed", count)
  22. } else {
  23. logger.Warn("%d users with wrong type exist", count)
  24. }
  25. }
  26. return nil
  27. }
  28. func init() {
  29. Register(&Check{
  30. Title: "Check if user with wrong type exist",
  31. Name: "check-user-type",
  32. IsDefault: true,
  33. Run: checkUserType,
  34. Priority: 3,
  35. })
  36. }