loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: load settings for valid user and email check (#6674)

- The doctor commands to check the validity of existing usernames and
email addresses depend on functionality that have configurable behavior
depending on the values of the `[service]` settings, so load them when
running the doctor command.
- Resolves #6664
- No unit test due to the architecture of doctor commands.

# Testing

1. Set `[service].ALLOW_DOTS_IN_USERNAMES = true`.
2. Create a user that contains a dot in their username.
3. Run the `check-user-name` doctor command and verify there's no error reported.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6674
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Co-authored-by: Gusted <postmaster@gusted.xyz>
Co-committed-by: Gusted <postmaster@gusted.xyz>

authored by

Gusted
Gusted
and committed by
Gusted
46e60ce9 8f8856dc

+10
+5
modules/setting/service.go
··· 140 140 return globs 141 141 } 142 142 143 + // LoadServiceSetting loads the service settings 144 + func LoadServiceSetting() { 145 + loadServiceFrom(CfgProvider) 146 + } 147 + 143 148 func loadServiceFrom(rootCfg ConfigProvider) { 144 149 sec := rootCfg.Section("service") 145 150 Service.ActiveCodeLives = sec.Key("ACTIVE_CODE_LIVE_MINUTES").MustInt(180)
+5
services/doctor/breaking.go
··· 10 10 "code.gitea.io/gitea/models/db" 11 11 "code.gitea.io/gitea/models/user" 12 12 "code.gitea.io/gitea/modules/log" 13 + "code.gitea.io/gitea/modules/setting" 13 14 "code.gitea.io/gitea/modules/validation" 14 15 15 16 "xorm.io/builder" ··· 30 31 // addresses would be currently facing a error due to their invalid email address. 31 32 // Ref: https://github.com/go-gitea/gitea/pull/19085 & https://github.com/go-gitea/gitea/pull/17688 32 33 func checkUserEmail(ctx context.Context, logger log.Logger, _ bool) error { 34 + setting.LoadServiceSetting() 35 + 33 36 // We could use quirky SQL to get all users that start without a [a-zA-Z0-9], but that would mean 34 37 // DB provider-specific SQL and only works _now_. So instead we iterate through all user accounts 35 38 // and use the validation.ValidateEmail function to be future-proof. ··· 61 64 // are allowed for various reasons. This check helps with detecting users that, according 62 65 // to our reserved names, don't have a valid username. 63 66 func checkUserName(ctx context.Context, logger log.Logger, _ bool) error { 67 + setting.LoadServiceSetting() 68 + 64 69 var invalidUserCount int64 65 70 if err := iterateUserAccounts(ctx, func(u *user.User) error { 66 71 if err := user.IsUsableUsername(u.Name); err != nil {