Skip to content

Commit

Permalink
feat: skip GetUserCount() if there is no quota limit (casdoor#3491)
Browse files Browse the repository at this point in the history
  • Loading branch information
dacongda authored Jan 10, 2025
1 parent fcfb73a commit b96fa2a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 1 addition & 7 deletions controllers/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,13 +353,7 @@ func (c *ApiController) AddUser() {
return
}

count, err := object.GetUserCount("", "", "", "")
if err != nil {
c.ResponseError(err.Error())
return
}

if err := checkQuotaForUser(int(count)); err != nil {
if err := checkQuotaForUser(); err != nil {
c.ResponseError(err.Error())
return
}
Expand Down
10 changes: 8 additions & 2 deletions controllers/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,18 @@ func checkQuotaForProvider(count int) error {
return nil
}

func checkQuotaForUser(count int) error {
func checkQuotaForUser() error {
quota := conf.GetConfigQuota().User
if quota == -1 {
return nil
}
if count >= quota {

count, err := object.GetUserCount("", "", "", "")
if err != nil {
return err
}

if int(count) >= quota {
return fmt.Errorf("user quota is exceeded")
}
return nil
Expand Down

0 comments on commit b96fa2a

Please sign in to comment.