0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-10 00:58:26 -05:00

Improve posible race condition handling on user registration.

This commit is contained in:
Andrey Antukh 2021-02-03 23:27:47 +01:00 committed by Hirunatan
parent 6e08c6bc35
commit 992a8e9aef

View file

@ -170,15 +170,24 @@
active? (if demo? true is-active)
props (db/tjson (or props {}))
password (derive-password password)]
(-> (db/insert! conn :profile
{:id id
:fullname fullname
:email (str/lower email)
:password password
:props props
:is-active active?
:is-demo demo?})
(update :props db/decode-transit-pgobject))))
(try
(-> (db/insert! conn :profile
{:id id
:fullname fullname
:email (str/lower email)
:password password
:props props
:is-active active?
:is-demo demo?})
(update :props db/decode-transit-pgobject))
(catch org.postgresql.util.PSQLException e
(let [state (.getSQLState e)]
(if (not= state "23505")
(throw e)
(ex/raise :type :validation
:code :email-already-exists
:cause e)))))))
(defn- create-profile-relations
[conn profile]