From fdd36d48bc53b7e5787e8b288ecea8ff1c06a966 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Fri, 8 Jan 2021 14:12:56 +0100 Subject: [PATCH] :bug: Disable authentication for :login-or-register. --- backend/src/app/http/errors.clj | 5 +++++ backend/src/app/rpc.clj | 4 +++- backend/src/app/rpc/mutations/profile.clj | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/backend/src/app/http/errors.clj b/backend/src/app/http/errors.clj index 19693b184..9c6b762e7 100644 --- a/backend/src/app/http/errors.clj +++ b/backend/src/app/http/errors.clj @@ -38,6 +38,11 @@ {:status 403 :body (ex-data err)}) +(defmethod handle-exception :authentication + [err _] + {:status 401 + :body (ex-data err)}) + (defmethod handle-exception :validation [err req] (let [header (get-in req [:headers "accept"]) diff --git a/backend/src/app/rpc.clj b/backend/src/app/rpc.clj index ee7d2d4b9..8929d12fe 100644 --- a/backend/src/app/rpc.clj +++ b/backend/src/app/rpc.clj @@ -68,7 +68,9 @@ (log/debugf "Registering '%s' command to rpc service." (::sv/name mdata)) (fn [params] (when (and (:auth mdata true) (not (uuid? (:profile-id params)))) - (ex/raise :type :not-authenticated)) + (ex/raise :type :authentication + :code :authentication-required + :hint "authentication required for this endpoint" (f cfg (us/conform spec params))))) (defn- process-method diff --git a/backend/src/app/rpc/mutations/profile.clj b/backend/src/app/rpc/mutations/profile.clj index ebe000f02..f02c34630 100644 --- a/backend/src/app/rpc/mutations/profile.clj +++ b/backend/src/app/rpc/mutations/profile.clj @@ -228,7 +228,7 @@ ;; --- Mutation: Register if not exists -(sv/defmethod ::login-or-register +(sv/defmethod ::login-or-register {:auth false} [{:keys [pool] :as cfg} {:keys [email fullname] :as params}] (letfn [(populate-additional-data [conn profile] (let [data (profile/retrieve-additional-data conn (:id profile))]