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:
parent
2fef3dc881
commit
d98fd76032
2 changed files with 45 additions and 0 deletions
|
@ -10,6 +10,7 @@
|
||||||
[app.common.logging :as l]
|
[app.common.logging :as l]
|
||||||
[app.common.spec :as us]
|
[app.common.spec :as us]
|
||||||
[app.config :as cf]
|
[app.config :as cf]
|
||||||
|
[app.srepl.ext]
|
||||||
[app.srepl.main]
|
[app.srepl.main]
|
||||||
[app.util.json :as json]
|
[app.util.json :as json]
|
||||||
[app.util.locks :as locks]
|
[app.util.locks :as locks]
|
||||||
|
|
44
backend/src/app/srepl/ext.clj
Normal file
44
backend/src/app/srepl/ext.clj
Normal 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))))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue