mirror of
https://github.com/penpot/penpot.git
synced 2026-08-01 19:06:18 +00:00
✨ Simplify reset-password srepl helper
This commit is contained in:
parent
85591bd579
commit
7a44426c4b
@ -15,7 +15,7 @@
|
|||||||
[app.common.features :as cfeat]
|
[app.common.features :as cfeat]
|
||||||
[app.common.files.validate :as cfv]
|
[app.common.files.validate :as cfv]
|
||||||
[app.common.logging :as l]
|
[app.common.logging :as l]
|
||||||
[app.common.pprint :as p]
|
[app.common.pprint :as pp]
|
||||||
[app.common.schema :as sm]
|
[app.common.schema :as sm]
|
||||||
[app.common.spec :as us]
|
[app.common.spec :as us]
|
||||||
[app.common.time :as ct]
|
[app.common.time :as ct]
|
||||||
@ -58,7 +58,7 @@
|
|||||||
(defn print-tasks
|
(defn print-tasks
|
||||||
[]
|
[]
|
||||||
(let [tasks (:app.worker/registry main/system)]
|
(let [tasks (:app.worker/registry main/system)]
|
||||||
(p/pprint (keys tasks) :level 200)))
|
(pp/pprint (keys tasks) :level 200)))
|
||||||
|
|
||||||
(defn run-task!
|
(defn run-task!
|
||||||
([tname]
|
([tname]
|
||||||
@ -130,18 +130,18 @@
|
|||||||
(defn reset-password!
|
(defn reset-password!
|
||||||
"Reset a password to a specific one for a concrete user or all users
|
"Reset a password to a specific one for a concrete user or all users
|
||||||
if email is `:all` keyword."
|
if email is `:all` keyword."
|
||||||
[& {:keys [email password] :or {password "123123"} :as params}]
|
[& {:keys [email password]}]
|
||||||
(when-not email
|
(assert (string? email) "expected email")
|
||||||
(throw (IllegalArgumentException. "email is mandatory")))
|
(assert (string? password) "expected password")
|
||||||
|
|
||||||
(some-> main/system
|
(some-> main/system
|
||||||
(db/tx-run!
|
(db/tx-run!
|
||||||
(fn [{:keys [::db/conn] :as system}]
|
(fn [{:keys [::db/conn] :as system}]
|
||||||
(let [password (derive-password password)]
|
(let [password (derive-password password)
|
||||||
(if (= email :all)
|
email (str/lower email)]
|
||||||
(db/exec! conn ["update profile set password=?" password])
|
(-> (db/exec-one! conn ["update profile set password=? where email=?" password email])
|
||||||
(let [email (str/lower email)]
|
(db/get-update-count)
|
||||||
(db/exec! conn ["update profile set password=? where email=?" password email]))))))))
|
(pos?)))))))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; FEATURES
|
;; FEATURES
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user