mirror of
https://github.com/penpot/penpot.git
synced 2025-02-12 18:18:24 -05:00
🎉 Add new approach to update http response from services.
This commit is contained in:
parent
d4cb868503
commit
f427c6f8b6
3 changed files with 20 additions and 15 deletions
|
@ -34,8 +34,7 @@
|
|||
{::sq/type type})
|
||||
data (cond-> data
|
||||
(:profile-id req) (assoc :profile-id (:profile-id req)))]
|
||||
(if (or (:profile-id req)
|
||||
(contains? unauthorized-services type))
|
||||
(if (or (:profile-id req) (contains? unauthorized-services type))
|
||||
{:status 200
|
||||
:body (sq/handle (with-meta data {:req req}))}
|
||||
{:status 403
|
||||
|
@ -51,18 +50,14 @@
|
|||
{::sm/type type})
|
||||
data (cond-> data
|
||||
(:profile-id req) (assoc :profile-id (:profile-id req)))]
|
||||
(if (or (:profile-id req)
|
||||
(contains? unauthorized-services type))
|
||||
(let [body (sm/handle (with-meta data {:req req}))]
|
||||
(if (= type :delete-profile)
|
||||
(do
|
||||
(some-> (session/extract-auth-token req)
|
||||
(session/delete))
|
||||
{:status 204
|
||||
:cookies (session/cookies "" {:max-age -1})
|
||||
:body ""})
|
||||
{:status 200
|
||||
:body body}))
|
||||
(if (or (:profile-id req) (contains? unauthorized-services type))
|
||||
(let [result (sm/handle (with-meta data {:req req}))
|
||||
mdata (meta result)
|
||||
resp {:status (if (nil? (seq result)) 204 200)
|
||||
:body result}]
|
||||
(cond->> resp
|
||||
(:transform-response mdata) ((:transform-response mdata) req)))
|
||||
|
||||
{:status 403
|
||||
:body {:type :authentication
|
||||
:code :unauthorized}})))
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
;;
|
||||
;; Copyright (c) 2020 UXBOX Labs SL
|
||||
|
||||
;; TODO: move to services.
|
||||
|
||||
(ns app.http.session
|
||||
(:require
|
||||
[app.db :as db]
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
[app.emails :as emails]
|
||||
[app.media :as media]
|
||||
[app.media-storage :as mst]
|
||||
[app.http.session :as session]
|
||||
[app.services.mutations :as sm]
|
||||
[app.services.mutations.media :as media-mutations]
|
||||
[app.services.mutations.projects :as projects]
|
||||
|
@ -473,7 +474,14 @@
|
|||
(db/update! conn :profile
|
||||
{:deleted-at (dt/now)}
|
||||
{:id profile-id})
|
||||
nil))
|
||||
|
||||
(with-meta {}
|
||||
{:transform-response
|
||||
(fn [request response]
|
||||
(some-> (session/extract-auth-token request)
|
||||
(session/delete))
|
||||
(assoc response
|
||||
:cookies (session/cookies "" {:max-age -1})))})))
|
||||
|
||||
(def ^:private sql:teams-ownership-check
|
||||
"with teams as (
|
||||
|
|
Loading…
Add table
Reference in a new issue