]> source.dussan.org Git - gitea.git/commitdiff
Fix new user form for non-local users (#8826)
authorLauris BH <lauris@nix.lv>
Mon, 4 Nov 2019 19:10:37 +0000 (21:10 +0200)
committerGitHub <noreply@github.com>
Mon, 4 Nov 2019 19:10:37 +0000 (21:10 +0200)
routers/admin/users.go
templates/admin/user/new.tmpl

index fdc4e0e371b41c44b286289d112b3b63fca6aa5b..2284f21838c6a71ab0695a00e736acbe3887c0b9 100644 (file)
@@ -79,12 +79,11 @@ func NewUserPost(ctx *context.Context, form auth.AdminCreateUserForm) {
        }
 
        u := &models.User{
-               Name:               form.UserName,
-               Email:              form.Email,
-               Passwd:             form.Password,
-               IsActive:           true,
-               LoginType:          models.LoginPlain,
-               MustChangePassword: form.MustChangePassword,
+               Name:      form.UserName,
+               Email:     form.Email,
+               Passwd:    form.Password,
+               IsActive:  true,
+               LoginType: models.LoginPlain,
        }
 
        if len(form.LoginType) > 0 {
@@ -95,9 +94,12 @@ func NewUserPost(ctx *context.Context, form auth.AdminCreateUserForm) {
                        u.LoginName = form.LoginName
                }
        }
-       if !password.IsComplexEnough(form.Password) {
-               ctx.RenderWithErr(ctx.Tr("form.password_complexity"), tplUserNew, &form)
-               return
+       if u.LoginType == models.LoginPlain {
+               if !password.IsComplexEnough(form.Password) {
+                       ctx.RenderWithErr(ctx.Tr("form.password_complexity"), tplUserNew, &form)
+                       return
+               }
+               u.MustChangePassword = form.MustChangePassword
        }
        if err := models.CreateUser(u); err != nil {
                switch {
index b9e326e73495cbcc2926e7716d30759aa358f089..06b7d70efe3568ff5adf21b8bcd1fa3f6a3a0ca9 100644 (file)
@@ -42,7 +42,7 @@
                                        <input id="password" name="password" type="password" value="{{.password}}" {{if eq .login_type "0-0"}}required{{end}}>
                                </div>
 
-                               <div class="inline field">
+                               <div class="inline field local{{if ne .login_type "0-0"}} hide{{end}}">
                                        <div class="ui checkbox">
                                                <label><strong>{{.i18n.Tr "auth.allow_password_change" }}</strong></label>
                                                <input name="must_change_password" type="checkbox" checked>