From 26457782c120da990a5b6a509fd45db7e75f7e63 Mon Sep 17 00:00:00 2001 From: Lauris BH Date: Tue, 5 Nov 2019 02:19:32 +0200 Subject: [PATCH] Fix new user form for non-local users (#8826) (#8828) --- routers/admin/users.go | 20 +++++++++++--------- templates/admin/user/new.tmpl | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/routers/admin/users.go b/routers/admin/users.go index fdc4e0e371b4..2284f21838c6 100644 --- a/routers/admin/users.go +++ b/routers/admin/users.go @@ -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 { diff --git a/templates/admin/user/new.tmpl b/templates/admin/user/new.tmpl index b9e326e73495..06b7d70efe35 100644 --- a/templates/admin/user/new.tmpl +++ b/templates/admin/user/new.tmpl @@ -42,7 +42,7 @@ -
+