Skip to content

Conversation

@techknowlogick
Copy link
Member

Fix #29975

WIP as it should have tests & am unsure if there is enough documentation

@techknowlogick techknowlogick added the type/feature Completely new functionality. Can only be merged if feature freeze is not active. label Apr 1, 2024
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Apr 1, 2024
@github-actions github-actions bot added modifies/go Pull requests that update Go code modifies/docs labels Apr 1, 2024
return committer.Commit()
}

func HitCreationLimit(ctx context.Context) bool {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NoMoreUsersAllowed?

@delvh delvh changed the title Limit the number of users on an instace Limit the number of users on an instance Apr 1, 2024
Co-authored-by: delvh <dev.lh@web.de>
@pull-request-size pull-request-size bot added size/M and removed size/S labels Apr 2, 2024
@delvh
Copy link
Member

delvh commented Apr 2, 2024

I am unsure if there is enough documentation

I mean, what more do you want to document about it?
Given our remaining documentation, it is already covered to a satisfactory extent.
You can of course add more documentation, but I don't see where or what.

But the tests would be nice, to ensure it doesn't just break at one point.

func HitCreationLimit(ctx context.Context) bool {
// don't bother calling DB if limit not set
if setting.Service.MaxUserCreationLimit < 0 ||
int64(setting.Service.MaxUserCreationLimit) < CountUsers(ctx, &CountUserFilter{}) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be a concurrent limit? Deactivated users should not be counted.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, doing this means we also need to keep the user count in mind when re-activating a user, and the CountUsers must ignore deactivated users.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this feature should be similar to "you have 10 user licenses". Usually if someone leaves, you just deactivate the account and get 1 license back. This would not be possible with the current code.

func HitCreationLimit(ctx context.Context) bool {
// don't bother calling DB if limit not set
if setting.Service.MaxUserCreationLimit < 0 ||
int64(setting.Service.MaxUserCreationLimit) < CountUsers(ctx, &CountUserFilter{}) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this feature should be similar to "you have 10 user licenses". Usually if someone leaves, you just deactivate the account and get 1 license back. This would not be possible with the current code.

}

// Check the number of users already in the system, and if there are too many forbid any new ones.
if user_model.HitCreationLimit(ctx) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the user is created auto-active there is no limit?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. modifies/docs modifies/go Pull requests that update Go code type/feature Completely new functionality. Can only be merged if feature freeze is not active.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Limit the Number of Users a Gitea Deployment Can Have

4 participants