Skip to content

Commit 8d64c53

Browse files
committed
fix
1 parent 4d1277c commit 8d64c53

File tree

6 files changed

+7
-18
lines changed

6 files changed

+7
-18
lines changed

models/auth/source.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -261,16 +261,12 @@ func (opts FindSourcesOptions) ToConds() builder.Cond {
261261
// IsSSPIEnabled returns true if there is at least one activated login
262262
// source of type LoginSSPI
263263
func IsSSPIEnabled(ctx context.Context) bool {
264-
if !db.HasEngine {
265-
return false
266-
}
267-
268264
exist, err := db.Exist[Source](ctx, FindSourcesOptions{
269265
IsActive: util.OptionalBoolTrue,
270266
LoginType: SSPI,
271267
}.ToConds())
272268
if err != nil {
273-
log.Error("Active SSPI Sources: %v", err)
269+
log.Error("IsSSPIEnabled: failed to query active SSPI sources: %v", err)
274270
return false
275271
}
276272
return exist

models/db/engine.go

-3
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ var (
2727
x *xorm.Engine
2828
tables []any
2929
initFuncs []func() error
30-
31-
// HasEngine specifies if we have a xorm.Engine
32-
HasEngine bool
3330
)
3431

3532
// Engine represents a xorm engine or session.

modules/setting/server.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,7 @@ func loadServerFrom(rootCfg ConfigProvider) {
341341
LandingPageURL = LandingPageOrganizations
342342
case "login":
343343
LandingPageURL = LandingPageLogin
344-
case "":
345-
case "home":
344+
case "", "home":
346345
LandingPageURL = LandingPageHome
347346
default:
348347
LandingPageURL = LandingPage(landingPage)

modules/web/middleware/data.go

-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ func GetContextData(c context.Context) ContextData {
4747

4848
func CommonTemplateContextData() ContextData {
4949
return ContextData{
50-
"IsLandingPageOrganizations": setting.LandingPageURL == setting.LandingPageOrganizations,
51-
5250
"ShowRegistrationButton": setting.Service.ShowRegistrationButton,
5351
"ShowMilestonesDashboardPage": setting.Service.ShowMilestonesDashboardPage,
5452
"ShowFooterVersion": setting.Other.ShowFooterVersion,

routers/common/db.go

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ func InitDBEngine(ctx context.Context) (err error) {
3737
log.Info("Backing off for %d seconds", int64(setting.Database.DBConnectBackoff/time.Second))
3838
time.Sleep(setting.Database.DBConnectBackoff)
3939
}
40-
db.HasEngine = true
4140
config.SetDynGetter(system_model.NewDatabaseDynKeyGetter())
4241
return nil
4342
}

routers/web/auth/auth.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ const (
4545

4646
// autoSignIn reads cookie and try to auto-login.
4747
func autoSignIn(ctx *context.Context) (bool, error) {
48-
if !db.HasEngine {
49-
return false, nil
50-
}
51-
5248
isSucceed := false
5349
defer func() {
5450
if !isSucceed {
@@ -145,7 +141,11 @@ func CheckAutoLogin(ctx *context.Context) bool {
145141

146142
if isSucceed {
147143
middleware.DeleteRedirectToCookie(ctx.Resp)
148-
ctx.RedirectToFirst(redirectTo, setting.AppSubURL+string(setting.LandingPageURL))
144+
nextRedirectTo := setting.AppSubURL + string(setting.LandingPageURL)
145+
if setting.LandingPageURL == setting.LandingPageLogin {
146+
nextRedirectTo = setting.AppSubURL // do not cycle-redirect to the login page
147+
}
148+
ctx.RedirectToFirst(redirectTo, nextRedirectTo)
149149
return true
150150
}
151151

0 commit comments

Comments
 (0)