From 3d043adb030776d5dcb5db027cdec3c4f8b70db9 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 9 Mar 2021 21:38:22 +0100 Subject: [PATCH] :bug: Fix wrong handling of deleted users on password recovery. --- backend/src/app/rpc/queries/profile.clj | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/backend/src/app/rpc/queries/profile.clj b/backend/src/app/rpc/queries/profile.clj index 59ed2e8b0..29fb1124b 100644 --- a/backend/src/app/rpc/queries/profile.clj +++ b/backend/src/app/rpc/queries/profile.clj @@ -13,10 +13,8 @@ [app.common.spec :as us] [app.common.uuid :as uuid] [app.db :as db] - [app.db.sql :as sql] [app.util.services :as sv] - [clojure.spec.alpha :as s] - [cuerdas.core :as str])) + [clojure.spec.alpha :as s])) ;; --- Helpers & Specs @@ -97,12 +95,16 @@ profile)) +(def sql:retrieve-profile-by-email + "select p.* from profile as p + where p.email = lower(?) + and p.deleted_at is null") + (defn retrieve-profile-data-by-email [conn email] - (let [sql (sql/select :profile {:email (str/lower email)}) - data (db/exec-one! conn sql)] - (when (and data (nil? (:deleted-at data))) - (decode-profile-row data)))) + (let [sql [sql:retrieve-profile-by-email email]] + (some-> (db/exec-one! conn sql) + (decode-profile-row)))) ;; --- Attrs Helpers