Skip to content

Commit 70334a6

Browse files
author
Earl Warren
committed
[v7.0/forgejo] fix: load settings for valid user and email check (#6679)
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6679 Reviewed-by: Earl Warren <[email protected]>
2 parents 9cc7b6d + 51e0b34 commit 70334a6

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

modules/setting/service.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ func CompileEmailGlobList(sec ConfigSection, keys ...string) (globs []glob.Glob)
133133
return globs
134134
}
135135

136+
// LoadServiceSetting loads the service settings
137+
func LoadServiceSetting() {
138+
loadServiceFrom(CfgProvider)
139+
}
140+
136141
func loadServiceFrom(rootCfg ConfigProvider) {
137142
sec := rootCfg.Section("service")
138143
Service.ActiveCodeLives = sec.Key("ACTIVE_CODE_LIVE_MINUTES").MustInt(180)

services/doctor/breaking.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"code.gitea.io/gitea/models/db"
1111
"code.gitea.io/gitea/models/user"
1212
"code.gitea.io/gitea/modules/log"
13+
"code.gitea.io/gitea/modules/setting"
1314

1415
"xorm.io/builder"
1516
)
@@ -29,6 +30,8 @@ func iterateUserAccounts(ctx context.Context, each func(*user.User) error) error
2930
// addresses would be currently facing a error due to their invalid email address.
3031
// Ref: https://github.com/go-gitea/gitea/pull/19085 & https://github.com/go-gitea/gitea/pull/17688
3132
func checkUserEmail(ctx context.Context, logger log.Logger, _ bool) error {
33+
setting.LoadServiceSetting()
34+
3235
// We could use quirky SQL to get all users that start without a [a-zA-Z0-9], but that would mean
3336
// DB provider-specific SQL and only works _now_. So instead we iterate through all user accounts
3437
// and use the user.ValidateEmail function to be future-proof.
@@ -60,6 +63,8 @@ func checkUserEmail(ctx context.Context, logger log.Logger, _ bool) error {
6063
// are allowed for various reasons. This check helps with detecting users that, according
6164
// to our reserved names, don't have a valid username.
6265
func checkUserName(ctx context.Context, logger log.Logger, _ bool) error {
66+
setting.LoadServiceSetting()
67+
6368
var invalidUserCount int64
6469
if err := iterateUserAccounts(ctx, func(u *user.User) error {
6570
if err := user.IsUsableUsername(u.Name); err != nil {

0 commit comments

Comments
 (0)