mirror of
https://github.com/drakkan/sftpgo.git
synced 2024-11-21 23:20:24 +00:00
web user templates: ensure we can save valid users
users with no public key and password are now valid after the recent changes Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
parent
55f8171dd1
commit
3521bacc4a
2 changed files with 7 additions and 7 deletions
|
@ -15410,9 +15410,9 @@ func TestUserTemplateMock(t *testing.T) {
|
|||
checkResponseCode(t, http.StatusBadRequest, rr)
|
||||
require.Contains(t, rr.Body.String(), "Error validating user")
|
||||
|
||||
form.Set("tpl_username", "user1")
|
||||
form.Set("tpl_password", " ")
|
||||
form.Set("tpl_public_keys", "")
|
||||
form.Set("tpl_username", " ")
|
||||
form.Set("tpl_password", "pwd")
|
||||
form.Set("tpl_public_keys", testPubKey)
|
||||
b, contentType, _ = getMultipartFormData(form, "", "")
|
||||
req, _ = http.NewRequest(http.MethodPost, webTemplateUser, &b)
|
||||
setJWTCookieForReq(req, token)
|
||||
|
@ -15427,9 +15427,9 @@ func TestUserTemplateMock(t *testing.T) {
|
|||
form.Add("tpl_username", "user2")
|
||||
form.Add("tpl_password", "password2")
|
||||
form.Add("tpl_public_keys", testPubKey)
|
||||
form.Add("tpl_username", "user3")
|
||||
form.Add("tpl_password", "")
|
||||
form.Add("tpl_public_keys", "")
|
||||
form.Add("tpl_username", "")
|
||||
form.Add("tpl_password", "password3")
|
||||
form.Add("tpl_public_keys", testPubKey)
|
||||
b, contentType, _ = getMultipartFormData(form, "", "")
|
||||
req, _ = http.NewRequest(http.MethodPost, webTemplateUser, &b)
|
||||
setJWTCookieForReq(req, token)
|
||||
|
|
|
@ -705,7 +705,7 @@ func getUsersForTemplate(r *http.Request) []userTemplateFields {
|
|||
if len(tplPublicKeys) > idx {
|
||||
publicKey = strings.TrimSpace(tplPublicKeys[idx])
|
||||
}
|
||||
if username == "" || (password == "" && publicKey == "") {
|
||||
if username == "" {
|
||||
continue
|
||||
}
|
||||
if _, ok := users[username]; ok {
|
||||
|
|
Loading…
Reference in a new issue