mirror of
				https://github.com/go-gitea/gitea
				synced 2025-10-30 19:08:37 +00:00 
			
		
		
		
	Backport #29583
This commit is contained in:
		| @@ -109,9 +109,21 @@ func resetLocale(ctx *context.Context, u *user_model.User) error { | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func RedirectAfterLogin(ctx *context.Context) { | ||||
| 	redirectTo := ctx.FormString("redirect_to") | ||||
| 	if redirectTo == "" { | ||||
| 		redirectTo = ctx.GetSiteCookie("redirect_to") | ||||
| 	} | ||||
| 	middleware.DeleteRedirectToCookie(ctx.Resp) | ||||
| 	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) | ||||
| } | ||||
|  | ||||
| func checkAutoLogin(ctx *context.Context) bool { | ||||
| 	// Check auto-login | ||||
| 	isSucceed, err := AutoSignIn(ctx) | ||||
| 	isSucceed, err := AutoSignIn(ctx) // try to auto-login | ||||
| 	if err != nil { | ||||
| 		ctx.ServerError("AutoSignIn", err) | ||||
| 		return true | ||||
| @@ -120,17 +132,10 @@ func checkAutoLogin(ctx *context.Context) bool { | ||||
| 	redirectTo := ctx.FormString("redirect_to") | ||||
| 	if len(redirectTo) > 0 { | ||||
| 		middleware.SetRedirectToCookie(ctx.Resp, redirectTo) | ||||
| 	} else { | ||||
| 		redirectTo = ctx.GetSiteCookie("redirect_to") | ||||
| 	} | ||||
|  | ||||
| 	if isSucceed { | ||||
| 		middleware.DeleteRedirectToCookie(ctx.Resp) | ||||
| 		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) | ||||
| 		RedirectAfterLogin(ctx) | ||||
| 		return true | ||||
| 	} | ||||
|  | ||||
| @@ -146,6 +151,10 @@ func SignIn(ctx *context.Context) { | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	if ctx.IsSigned { | ||||
| 		RedirectAfterLogin(ctx) | ||||
| 		return | ||||
| 	} | ||||
| 	orderedOAuth2Names, oauth2Providers, err := oauth2.GetOAuth2ProvidersMap(true) | ||||
| 	if err != nil { | ||||
| 		ctx.ServerError("UserSignIn", err) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user