Fixed bug where password could be blanked if a user was edited and no new password set

This commit is contained in:
Simon Brooke 2017-09-11 07:53:36 +01:00
parent 656d503128
commit 75c5618239
3 changed files with 12 additions and 4 deletions

View file

@ -1 +1 @@
{:admin {:admin true, :email "info@weft.scot", :password "admin"}}
{:admin {:admin true, :email "info@weft.scot", :password "admin"}, :jenny {:email "jenny@auchencairn.org", :admin false, :password "$s0$f0801$1uniQfftB37G5e5GklJANQ==$kQ0+/YcCuaz2x5iYjwhNlDlnWX/exE/8pSC+R4C0WvQ="}}

View file

@ -133,7 +133,9 @@
(defn add-user
"Add a user to the passwd file with this `username`, initial password and `email` address and `admin` flag."
"Add a user to the passwd file with this `username`, initial password `newpass`,
`email` address and `admin` flag; *or*, modify an existing user. Return true
if user is successfully stored, false otherwise."
[username newpass email admin]
(timbre/info "Trying to add user " username)
(cond

View file

@ -69,10 +69,16 @@
check-pass (auth/evaluate-password pass1 pass2)
password (if (and pass1 (true? check-pass)) pass1)
stored (if
(and
(:email params)
(or
(nil? pass1)
(zero? (count pass1))
(true? check-pass)))
(auth/add-user target password (:email params) (:admin params)))
message (if stored (str (:save-user-success (util/get-messages request)) " " target "."))
error (if (and (:email params) (not stored))
error (if
(and (:email params) (not stored))
(str
(:save-user-fail (util/get-messages request))
" " target ". "