mirror of
https://github.com/penpot/penpot.git
synced 2025-05-15 09:36:40 +02:00
✨ Minor improvements on getting profile additional data.
This commit is contained in:
parent
645954bc7c
commit
129cc86e3b
2 changed files with 13 additions and 13 deletions
|
@ -242,10 +242,10 @@
|
||||||
profile)]
|
profile)]
|
||||||
|
|
||||||
(db/with-atomic [conn pool]
|
(db/with-atomic [conn pool]
|
||||||
(let [profile (-> (profile/retrieve-profile-data-by-email conn email)
|
(let [profile (->> (profile/retrieve-profile-data-by-email conn email)
|
||||||
(validate-profile)
|
(validate-profile)
|
||||||
(profile/strip-private-attrs))
|
(profile/strip-private-attrs)
|
||||||
profile (merge profile (profile/retrieve-additional-data conn (:id profile)))]
|
(profile/populate-additional-data conn))]
|
||||||
(if-let [token (:invitation-token params)]
|
(if-let [token (:invitation-token params)]
|
||||||
;; If the request comes with an invitation token, this means
|
;; If the request comes with an invitation token, this means
|
||||||
;; that user wants to accept it with different user. A very
|
;; that user wants to accept it with different user. A very
|
||||||
|
@ -293,11 +293,7 @@
|
||||||
|
|
||||||
(defn login-or-register
|
(defn login-or-register
|
||||||
[{:keys [conn] :as cfg} {:keys [email backend] :as params}]
|
[{:keys [conn] :as cfg} {:keys [email backend] :as params}]
|
||||||
(letfn [(populate-additional-data [conn profile]
|
(letfn [(create-profile [conn {:keys [fullname email]}]
|
||||||
(let [data (profile/retrieve-additional-data conn (:id profile))]
|
|
||||||
(merge profile data)))
|
|
||||||
|
|
||||||
(create-profile [conn {:keys [fullname email]}]
|
|
||||||
(db/insert! conn :profile
|
(db/insert! conn :profile
|
||||||
{:id (uuid/next)
|
{:id (uuid/next)
|
||||||
:fullname fullname
|
:fullname fullname
|
||||||
|
@ -315,7 +311,7 @@
|
||||||
|
|
||||||
(let [profile (profile/retrieve-profile-data-by-email conn email)
|
(let [profile (profile/retrieve-profile-data-by-email conn email)
|
||||||
profile (if profile
|
profile (if profile
|
||||||
(populate-additional-data conn profile)
|
(profile/populate-additional-data conn profile)
|
||||||
(register-profile conn params))]
|
(register-profile conn params))]
|
||||||
(profile/strip-private-attrs profile))))
|
(profile/strip-private-attrs profile))))
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,10 @@
|
||||||
{:default-team-id (:id team)
|
{:default-team-id (:id team)
|
||||||
:default-project-id (:id project)}))
|
:default-project-id (:id project)}))
|
||||||
|
|
||||||
|
(defn populate-additional-data
|
||||||
|
[conn profile]
|
||||||
|
(merge profile (retrieve-additional-data conn (:id profile))))
|
||||||
|
|
||||||
(defn decode-profile-row
|
(defn decode-profile-row
|
||||||
[{:keys [props] :as row}]
|
[{:keys [props] :as row}]
|
||||||
(cond-> row
|
(cond-> row
|
||||||
|
@ -83,9 +87,9 @@
|
||||||
|
|
||||||
(defn retrieve-profile
|
(defn retrieve-profile
|
||||||
[conn id]
|
[conn id]
|
||||||
(let [profile (some-> (retrieve-profile-data conn id)
|
(let [profile (some->> (retrieve-profile-data conn id)
|
||||||
(strip-private-attrs)
|
(strip-private-attrs)
|
||||||
(merge (retrieve-additional-data conn id)))]
|
(populate-additional-data conn))]
|
||||||
(when (nil? profile)
|
(when (nil? profile)
|
||||||
(ex/raise :type :not-found
|
(ex/raise :type :not-found
|
||||||
:hint "Object doest not exists."))
|
:hint "Object doest not exists."))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue