Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wxiaoguang committed Dec 28, 2023
1 parent 4d1277c commit 4ac5412
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 18 deletions.
6 changes: 1 addition & 5 deletions models/auth/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,16 +261,12 @@ func (opts FindSourcesOptions) ToConds() builder.Cond {
// IsSSPIEnabled returns true if there is at least one activated login
// source of type LoginSSPI
func IsSSPIEnabled(ctx context.Context) bool {
if !db.HasEngine {
return false
}

exist, err := db.Exist[Source](ctx, FindSourcesOptions{
IsActive: util.OptionalBoolTrue,
LoginType: SSPI,
}.ToConds())
if err != nil {
log.Error("Active SSPI Sources: %v", err)
log.Error("IsSSPIEnabled: failed to query active SSPI sources: %v", err)
return false
}
return exist
Expand Down
3 changes: 0 additions & 3 deletions models/db/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ var (
x *xorm.Engine
tables []any
initFuncs []func() error

// HasEngine specifies if we have a xorm.Engine
HasEngine bool
)

// Engine represents a xorm engine or session.
Expand Down
3 changes: 1 addition & 2 deletions modules/setting/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,7 @@ func loadServerFrom(rootCfg ConfigProvider) {
LandingPageURL = LandingPageOrganizations
case "login":
LandingPageURL = LandingPageLogin
case "":
case "home":
case "", "home":
LandingPageURL = LandingPageHome
default:
LandingPageURL = LandingPage(landingPage)
Expand Down
2 changes: 0 additions & 2 deletions modules/web/middleware/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ func GetContextData(c context.Context) ContextData {

func CommonTemplateContextData() ContextData {
return ContextData{
"IsLandingPageOrganizations": setting.LandingPageURL == setting.LandingPageOrganizations,

"ShowRegistrationButton": setting.Service.ShowRegistrationButton,
"ShowMilestonesDashboardPage": setting.Service.ShowMilestonesDashboardPage,
"ShowFooterVersion": setting.Other.ShowFooterVersion,
Expand Down
1 change: 0 additions & 1 deletion routers/common/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ func InitDBEngine(ctx context.Context) (err error) {
log.Info("Backing off for %d seconds", int64(setting.Database.DBConnectBackoff/time.Second))
time.Sleep(setting.Database.DBConnectBackoff)
}
db.HasEngine = true
config.SetDynGetter(system_model.NewDatabaseDynKeyGetter())
return nil
}
Expand Down
10 changes: 5 additions & 5 deletions routers/web/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ const (

// autoSignIn reads cookie and try to auto-login.
func autoSignIn(ctx *context.Context) (bool, error) {
if !db.HasEngine {
return false, nil
}

isSucceed := false
defer func() {
if !isSucceed {
Expand Down Expand Up @@ -145,7 +141,11 @@ func CheckAutoLogin(ctx *context.Context) bool {

if isSucceed {
middleware.DeleteRedirectToCookie(ctx.Resp)
ctx.RedirectToFirst(redirectTo, setting.AppSubURL+string(setting.LandingPageURL))
nextRedirectTo := setting.AppSubURL + string(setting.LandingPageURL)
if setting.LandingPageURL == setting.LandingPageLogin {
nextRedirectTo = setting.AppSubURL + "/" // do not cycle-redirect to the login page
}
ctx.RedirectToFirst(redirectTo, nextRedirectTo)
return true
}

Expand Down

0 comments on commit 4ac5412

Please sign in to comment.