0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-13 02:28:18 -05:00

🎉 Add namespace with a set of helpers for access throught the BREPL

This commit is contained in:
Andrey Antukh 2023-01-19 12:41:06 +01:00 committed by Andrés Moya
parent 2fef3dc881
commit d98fd76032
2 changed files with 45 additions and 0 deletions

View file

@ -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]

View file

@ -0,0 +1,44 @@
;; 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 password
:props {}}
profile (->> (cmd.auth/create-profile conn params)
(cmd.auth/create-profile-relations conn))]
(str (:id profile))))))