diff --git a/backend/src/app/srepl.clj b/backend/src/app/srepl.clj index cd5838a76..5885fa369 100644 --- a/backend/src/app/srepl.clj +++ b/backend/src/app/srepl.clj @@ -10,6 +10,7 @@ [app.common.logging :as l] [app.common.spec :as us] [app.config :as cf] + [app.srepl.ext] [app.srepl.main] [app.util.json :as json] [app.util.locks :as locks] diff --git a/backend/src/app/srepl/ext.clj b/backend/src/app/srepl/ext.clj new file mode 100644 index 000000000..640c6ee47 --- /dev/null +++ b/backend/src/app/srepl/ext.clj @@ -0,0 +1,42 @@ +;; This Source Code Form is subject to the terms of the Mozilla Public +;; License, v. 2.0. If a copy of the MPL was not distributed with this +;; file, You can obtain one at http://mozilla.org/MPL/2.0/. +;; +;; Copyright (c) KALEIDOS INC + +(ns app.srepl.ext + "PREPL API for external usage (CLI or ADMIN)" + (:require + [app.auth :as auth] + [app.common.uuid :as uuid] + [app.db :as db] + [app.rpc.commands.auth :as cmd.auth])) + +(defn- get-current-system + [] + (or (deref (requiring-resolve 'app.main/system)) + (deref (requiring-resolve 'user/system)))) + +(defn derive-password + [password] + (auth/derive-password password)) + +(defn create-profile + [fullname, email, password] + (when-let [system (get-current-system)] + (db/with-atomic [conn (:app.db/pool system)] + (let [params {:id (uuid/next) + :email email + :fullname fullname + :is-active true + :password (derive-password password) + :props {}} + profile (->> (cmd.auth/create-profile! conn params) + (cmd.auth/create-profile-rels! conn))] + (str (:id profile)))))) + + + + + +