mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 16:40:24 +08:00 
			
		
		
		
	Fix new user form for non-local users (#8826)
This commit is contained in:
		@@ -84,7 +84,6 @@ func NewUserPost(ctx *context.Context, form auth.AdminCreateUserForm) {
 | 
				
			|||||||
		Passwd:    form.Password,
 | 
							Passwd:    form.Password,
 | 
				
			||||||
		IsActive:  true,
 | 
							IsActive:  true,
 | 
				
			||||||
		LoginType: models.LoginPlain,
 | 
							LoginType: models.LoginPlain,
 | 
				
			||||||
		MustChangePassword: form.MustChangePassword,
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if len(form.LoginType) > 0 {
 | 
						if len(form.LoginType) > 0 {
 | 
				
			||||||
@@ -95,10 +94,13 @@ func NewUserPost(ctx *context.Context, form auth.AdminCreateUserForm) {
 | 
				
			|||||||
			u.LoginName = form.LoginName
 | 
								u.LoginName = form.LoginName
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						if u.LoginType == models.LoginPlain {
 | 
				
			||||||
		if !password.IsComplexEnough(form.Password) {
 | 
							if !password.IsComplexEnough(form.Password) {
 | 
				
			||||||
			ctx.RenderWithErr(ctx.Tr("form.password_complexity"), tplUserNew, &form)
 | 
								ctx.RenderWithErr(ctx.Tr("form.password_complexity"), tplUserNew, &form)
 | 
				
			||||||
			return
 | 
								return
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							u.MustChangePassword = form.MustChangePassword
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	if err := models.CreateUser(u); err != nil {
 | 
						if err := models.CreateUser(u); err != nil {
 | 
				
			||||||
		switch {
 | 
							switch {
 | 
				
			||||||
		case models.IsErrUserAlreadyExist(err):
 | 
							case models.IsErrUserAlreadyExist(err):
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -42,7 +42,7 @@
 | 
				
			|||||||
					<input id="password" name="password" type="password" value="{{.password}}" {{if eq .login_type "0-0"}}required{{end}}>
 | 
										<input id="password" name="password" type="password" value="{{.password}}" {{if eq .login_type "0-0"}}required{{end}}>
 | 
				
			||||||
				</div>
 | 
									</div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				<div class="inline field">
 | 
									<div class="inline field local{{if ne .login_type "0-0"}} hide{{end}}">
 | 
				
			||||||
					<div class="ui checkbox">
 | 
										<div class="ui checkbox">
 | 
				
			||||||
						<label><strong>{{.i18n.Tr "auth.allow_password_change" }}</strong></label>
 | 
											<label><strong>{{.i18n.Tr "auth.allow_password_change" }}</strong></label>
 | 
				
			||||||
						<input name="must_change_password" type="checkbox" checked>
 | 
											<input name="must_change_password" type="checkbox" checked>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user