fix: prevent 500 message on invalid username (#8236)
Bug introduced by #7998 ### Tests - go to your settings page https://v12.next.forgejo.org/user/settings - try to change to an invalid username (like `.well--invalid`) - verify that no 500 error is shown, only a flash message I tried to add a test in `tests/integration/user_test.go`, but failed to catch the error message: ``` resp := session.MakeRequest(t, req, http.StatusOK) txt := resp.Body.String() t.Log(txt) // no template error?? t.FailNow() ``` ### Release notes - [x] I do not want this change to show in the release notes. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8236 Reviewed-by: 0ko <0ko@noreply.codeberg.org> Co-authored-by: oliverpool <git@olivier.pfad.fr> Co-committed-by: oliverpool <git@olivier.pfad.fr>
This commit is contained in:
		
					parent
					
						
							
								968ba1bf84
							
						
					
				
			
			
				commit
				
					
						285f66b782
					
				
			
		
					 1 changed files with 3 additions and 0 deletions
				
			
		| 
						 | 
					@ -66,6 +66,9 @@ func ProfilePost(ctx *context.Context) {
 | 
				
			||||||
	ctx.Data["DisableGravatar"] = setting.Config().Picture.DisableGravatar.Value(ctx)
 | 
						ctx.Data["DisableGravatar"] = setting.Config().Picture.DisableGravatar.Value(ctx)
 | 
				
			||||||
	ctx.Data["CooldownPeriod"] = setting.Service.UsernameCooldownPeriod
 | 
						ctx.Data["CooldownPeriod"] = setting.Service.UsernameCooldownPeriod
 | 
				
			||||||
	ctx.Data["CommonPronouns"] = commonPronouns
 | 
						ctx.Data["CommonPronouns"] = commonPronouns
 | 
				
			||||||
 | 
						ctx.Data["MaxAvatarFileSize"] = setting.Avatar.MaxFileSize
 | 
				
			||||||
 | 
						ctx.Data["MaxAvatarWidth"] = setting.Avatar.MaxWidth
 | 
				
			||||||
 | 
						ctx.Data["MaxAvatarHeight"] = setting.Avatar.MaxHeight
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if ctx.HasError() {
 | 
						if ctx.HasError() {
 | 
				
			||||||
		ctx.HTML(http.StatusOK, tplSettingsProfile)
 | 
							ctx.HTML(http.StatusOK, tplSettingsProfile)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue