mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-29 10:57:44 +09:00 
			
		
		
		
	Avoid cycle-redirecting user/login page (#28636)
Fix #28231, and remove some unused code. The `db.HasEngine` doesn't seem useful because the db engine is always initialized before web route.
This commit is contained in:
		| @@ -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 { | ||||
| @@ -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 | ||||
| 	} | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user