mirror of
https://github.com/penpot/penpot.git
synced 2025-01-23 23:18:48 -05:00
✨ Improve srepl helpers for activate profile
This commit is contained in:
parent
67b4d5a1c7
commit
1298956d92
1 changed files with 12 additions and 25 deletions
|
@ -65,31 +65,18 @@
|
|||
(cmd.auth/send-email-verification! pool sprops profile)
|
||||
:email-sent))
|
||||
|
||||
(defn update-profile!
|
||||
"Update a limited set of profile attrs."
|
||||
[system & {:keys [email id active? deleted? blocked?]}]
|
||||
|
||||
(us/verify!
|
||||
:expr (some? system)
|
||||
:hint "system should be provided")
|
||||
|
||||
(us/verify!
|
||||
:expr (or (string? email) (uuid? id))
|
||||
:hint "email or id should be provided")
|
||||
|
||||
(let [params (cond-> {}
|
||||
(true? active?) (assoc :is-active true)
|
||||
(false? active?) (assoc :is-active false)
|
||||
(true? deleted?) (assoc :deleted-at (dt/now))
|
||||
(true? blocked?) (assoc :is-blocked true)
|
||||
(false? blocked?) (assoc :is-blocked false))
|
||||
opts (cond-> {}
|
||||
(some? email) (assoc :email (str/lower email))
|
||||
(some? id) (assoc :id id))]
|
||||
|
||||
(db/with-atomic [conn (:app.db/pool system)]
|
||||
(some-> (db/update! conn :profile params opts)
|
||||
(profile/decode-profile-row)))))
|
||||
(defn mark-profile-as-active!
|
||||
"Mark the profile blocked and removes all the http sessiones
|
||||
associated with the profile-id."
|
||||
[system email]
|
||||
(db/with-atomic [conn (:app.db/pool system)]
|
||||
(when-let [profile (db/get-by-params conn :profile
|
||||
{:email (str/lower email)}
|
||||
{:columns [:id :email]
|
||||
:check-not-found false})]
|
||||
(when-not (:is-blocked profile)
|
||||
(db/update! conn :profile {:is-active true} {:id (:id profile)})
|
||||
:activated))))
|
||||
|
||||
(defn mark-profile-as-blocked!
|
||||
"Mark the profile blocked and removes all the http sessiones
|
||||
|
|
Loading…
Add table
Reference in a new issue