Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix settings not being loaded at CLI #26402

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cassiozareck
Copy link
Contributor

@cassiozareck cassiozareck commented Aug 8, 2023

Closes #25898
The problem was that the default settings weren't being loaded, so

u.AllowCreateOrganization = setting.Service.DefaultAllowCreateOrganization && !setting.Admin.DisableRegularOrgCreation

was always false.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Aug 8, 2023
@pull-request-size pull-request-size bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Aug 8, 2023
@techknowlogick techknowlogick added type/bug backport/v1.20 This PR should be backported to Gitea 1.20 labels Aug 8, 2023
@silverwind
Copy link
Member

silverwind commented Aug 11, 2023

I wonder if this is really the right place to load the settings or if we should do it earlier. Doing it in the middle of command processing does seem odd.

@cassiozareck
Copy link
Contributor Author

Both way works as of my tests. I thought to initialize together with the DB but thinking better at the beginning may be more clean. I'll adjust it

Signed-off-by: cassiozareck <cassiomilczareck@gmail.com>
@silverwind
Copy link
Member

Ah I see the context now, previous place was fine then I guess, the validation does not depend on settings it looks like. Note I'm not really knowledgeable around these parts so take my comments with a grain of salt :)

@cassiozareck
Copy link
Contributor Author

cassiozareck commented Aug 11, 2023

As we're loading settings there's happening some output when a user runs gitea admin user create. Like this:

2023/08/11 10:34:13 ...les/setting/cache.go:75:loadCacheFrom() [I] Cache Service Enabled
2023/08/11 10:34:13 ...les/setting/cache.go:90:loadCacheFrom() [I] Last Commit Cache Service Enabled
2023/08/11 10:34:13 ...s/setting/session.go:74:loadSessionFrom() [I] Session Service Enabled
New user 'user1' has been successfully created!

@silverwind
Copy link
Member

That reinforces that it needs to be after validation.

@cassiozareck
Copy link
Contributor Author

Hmm so its ok? I think its unavoidable unless we try to change the config for logging outputs before

@silverwind
Copy link
Member

Just revert to previous location imho.

@cassiozareck
Copy link
Contributor Author

cassiozareck commented Aug 12, 2023

Oh no no! It happen doesn't matter where loadsetting is. There's log statements inside loadsettings. I think its alright as it states settings are being loaded but if you dont want log to happen I can see what I can do. I know I caused some confusion because it looked like I was saying because of position. Pls dont avoid my PRs 😆

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/v1.20 This PR should be backported to Gitea 1.20 lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create org permissions of user created via cli client
4 participants