mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-26 12:27:06 +00:00 
			
		
		
		
	fix display dashboard even if require to change password (#6214)
* fix display dashboard even if require to change password * fix comments
This commit is contained in:
		| @@ -44,23 +44,19 @@ func Toggle(options *ToggleOptions) macaron.Handler { | |||||||
| 				return | 				return | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			// prevent infinite redirection |  | ||||||
| 			// also make sure that the form cannot be accessed by |  | ||||||
| 			// users who don't need this |  | ||||||
| 			if ctx.Req.URL.Path == "/user/settings/change_password" { |  | ||||||
| 				if !ctx.User.MustChangePassword { |  | ||||||
| 					ctx.Redirect(setting.AppSubURL + "/") |  | ||||||
| 				} |  | ||||||
| 				return |  | ||||||
| 			} |  | ||||||
|  |  | ||||||
| 			if ctx.User.MustChangePassword { | 			if ctx.User.MustChangePassword { | ||||||
|  | 				if ctx.Req.URL.Path != "/user/settings/change_password" { | ||||||
| 					ctx.Data["Title"] = ctx.Tr("auth.must_change_password") | 					ctx.Data["Title"] = ctx.Tr("auth.must_change_password") | ||||||
| 					ctx.Data["ChangePasscodeLink"] = setting.AppSubURL + "/user/change_password" | 					ctx.Data["ChangePasscodeLink"] = setting.AppSubURL + "/user/change_password" | ||||||
| 					ctx.SetCookie("redirect_to", url.QueryEscape(setting.AppSubURL+ctx.Req.RequestURI), 0, setting.AppSubURL) | 					ctx.SetCookie("redirect_to", url.QueryEscape(setting.AppSubURL+ctx.Req.RequestURI), 0, setting.AppSubURL) | ||||||
| 					ctx.Redirect(setting.AppSubURL + "/user/settings/change_password") | 					ctx.Redirect(setting.AppSubURL + "/user/settings/change_password") | ||||||
| 					return | 					return | ||||||
| 				} | 				} | ||||||
|  | 			} else if ctx.Req.URL.Path == "/user/settings/change_password" { | ||||||
|  | 				// make sure that the form cannot be accessed by users who don't need this | ||||||
|  | 				ctx.Redirect(setting.AppSubURL + "/") | ||||||
|  | 				return | ||||||
|  | 			} | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		// Redirect to dashboard if user tries to visit any non-login page. | 		// Redirect to dashboard if user tries to visit any non-login page. | ||||||
|   | |||||||
| @@ -7,6 +7,7 @@ package routers | |||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"bytes" | 	"bytes" | ||||||
|  | 	"net/url" | ||||||
| 	"strings" | 	"strings" | ||||||
|  |  | ||||||
| 	"code.gitea.io/gitea/models" | 	"code.gitea.io/gitea/models" | ||||||
| @@ -44,6 +45,11 @@ func Home(ctx *context.Context) { | |||||||
| 			log.Info("Failed authentication attempt for %s from %s", ctx.User.Name, ctx.RemoteAddr()) | 			log.Info("Failed authentication attempt for %s from %s", ctx.User.Name, ctx.RemoteAddr()) | ||||||
| 			ctx.Data["Title"] = ctx.Tr("auth.prohibit_login") | 			ctx.Data["Title"] = ctx.Tr("auth.prohibit_login") | ||||||
| 			ctx.HTML(200, "user/auth/prohibit_login") | 			ctx.HTML(200, "user/auth/prohibit_login") | ||||||
|  | 		} else if ctx.User.MustChangePassword { | ||||||
|  | 			ctx.Data["Title"] = ctx.Tr("auth.must_change_password") | ||||||
|  | 			ctx.Data["ChangePasscodeLink"] = setting.AppSubURL + "/user/change_password" | ||||||
|  | 			ctx.SetCookie("redirect_to", url.QueryEscape(setting.AppSubURL+ctx.Req.RequestURI), 0, setting.AppSubURL) | ||||||
|  | 			ctx.Redirect(setting.AppSubURL + "/user/settings/change_password") | ||||||
| 		} else { | 		} else { | ||||||
| 			user.Dashboard(ctx) | 			user.Dashboard(ctx) | ||||||
| 		} | 		} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Lunny Xiao
					Lunny Xiao