mirror of
https://github.com/penpot/penpot.git
synced 2025-01-09 08:20:45 -05:00
✨ Rename sprops to setup module.
This commit is contained in:
parent
5b200fd6a2
commit
82d7a0163d
6 changed files with 38 additions and 42 deletions
|
@ -81,7 +81,7 @@
|
|||
{:id id
|
||||
:fullname (str "Profile " index)
|
||||
:password "123123"
|
||||
:demo? true
|
||||
:is-demo true
|
||||
:email (str "profile" index "@example.com")})
|
||||
team-id (:default-team-id prof)
|
||||
owner-id id]
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
{:uri (:redis-uri config)}
|
||||
|
||||
:app.tokens/tokens
|
||||
{:sprops (ig/ref :app.sprops/props)}
|
||||
{:sprops (ig/ref :app.setup/props)}
|
||||
|
||||
:app.storage/gc-deleted-task
|
||||
{:pool (ig/ref :app.db/pool)
|
||||
|
@ -295,13 +295,13 @@
|
|||
{:pool (ig/ref :app.db/pool)
|
||||
:version (:full cfg/version)
|
||||
:uri (:telemetry-uri config)
|
||||
:sprops (ig/ref :app.sprops/props)}
|
||||
:sprops (ig/ref :app.setup/props)}
|
||||
|
||||
:app.srepl/server
|
||||
{:port (:srepl-port config)
|
||||
:host (:srepl-host config)}
|
||||
|
||||
:app.sprops/props
|
||||
:app.setup/props
|
||||
{:pool (ig/ref :app.db/pool)}
|
||||
|
||||
:app.loggers.zmq/receiver
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
params {:id id
|
||||
:email email
|
||||
:fullname fullname
|
||||
:demo? true
|
||||
:is-demo true
|
||||
:password password
|
||||
:props {:onboarding-viewed true}}]
|
||||
|
||||
|
|
|
@ -163,28 +163,26 @@
|
|||
{:update false
|
||||
:valid false})))
|
||||
|
||||
(defn- create-profile
|
||||
(defn create-profile
|
||||
"Create the profile entry on the database with limited input
|
||||
filling all the other fields with defaults."
|
||||
[conn {:keys [id fullname email password demo? props is-active is-muted]
|
||||
:or {is-active false is-muted false}
|
||||
:as params}]
|
||||
(let [id (or id (uuid/next))
|
||||
demo? (if (boolean? demo?) demo? false)
|
||||
active? (if demo? true is-active)
|
||||
props (db/tjson (or props {}))
|
||||
password (derive-password password)]
|
||||
[conn {:keys [id fullname email password props is-active is-muted is-demo opts]
|
||||
:or {is-active false is-muted false is-demo false}}]
|
||||
(let [id (or id (uuid/next))
|
||||
is-active (if is-demo true is-active)
|
||||
props (db/tjson (or props {}))
|
||||
password (derive-password password)
|
||||
params {:id id
|
||||
:fullname fullname
|
||||
:email (str/lower email)
|
||||
:auth-backend "penpot"
|
||||
:password password
|
||||
:props props
|
||||
:is-active is-active
|
||||
:is-muted is-muted
|
||||
:is-demo is-demo}]
|
||||
(try
|
||||
(-> (db/insert! conn :profile
|
||||
{:id id
|
||||
:fullname fullname
|
||||
:email (str/lower email)
|
||||
:auth-backend "penpot"
|
||||
:password password
|
||||
:props props
|
||||
:is-active active?
|
||||
:is-muted is-muted
|
||||
:is-demo demo?})
|
||||
(-> (db/insert! conn :profile params opts)
|
||||
(update :props db/decode-transit-pgobject))
|
||||
(catch org.postgresql.util.PSQLException e
|
||||
(let [state (.getSQLState e)]
|
||||
|
@ -195,7 +193,7 @@
|
|||
:cause e)))))))
|
||||
|
||||
|
||||
(defn- create-profile-relations
|
||||
(defn create-profile-relations
|
||||
[conn profile]
|
||||
(let [team (teams/create-team conn {:profile-id (:id profile)
|
||||
:name "Default"
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
;;
|
||||
;; Copyright (c) 2020-2021 UXBOX Labs SL
|
||||
|
||||
(ns app.sprops
|
||||
"Server props module."
|
||||
(ns app.setup
|
||||
"Initial data setup of instance."
|
||||
(:require
|
||||
[app.common.uuid :as uuid]
|
||||
[app.db :as db]
|
||||
|
@ -17,16 +17,22 @@
|
|||
[clojure.spec.alpha :as s]
|
||||
[integrant.core :as ig]))
|
||||
|
||||
(declare initialize)
|
||||
(declare initialize-instance-id!)
|
||||
(declare initialize-secret-key!)
|
||||
(declare retrieve-all)
|
||||
|
||||
(defmethod ig/pre-init-spec ::props [_]
|
||||
(s/keys :req-un [::db/pool]))
|
||||
|
||||
(defmethod ig/init-key ::props
|
||||
[_ cfg]
|
||||
(initialize cfg))
|
||||
[_ {:keys [pool] :as cfg}]
|
||||
(db/with-atomic [conn pool]
|
||||
(let [cfg (assoc cfg :conn conn)]
|
||||
(initialize-secret-key! cfg)
|
||||
(initialize-instance-id! cfg)
|
||||
(retrieve-all cfg))))
|
||||
|
||||
(defn- initialize-secret-key
|
||||
(defn- initialize-secret-key!
|
||||
[{:keys [conn] :as cfg}]
|
||||
(let [key (-> (bn/random-bytes 64)
|
||||
(bc/bytes->b64u)
|
||||
|
@ -35,7 +41,7 @@
|
|||
values ('secret-key', ?) on conflict do nothing"
|
||||
(db/tjson key)])))
|
||||
|
||||
(defn- initialize-instance-id
|
||||
(defn- initialize-instance-id!
|
||||
[{:keys [conn] :as cfg}]
|
||||
(let [iid (uuid/random)]
|
||||
(db/exec-one! conn ["insert into server_prop (id, content)
|
||||
|
@ -48,11 +54,3 @@
|
|||
(assoc acc (keyword (:id row)) (db/decode-transit-pgobject (:content row))))
|
||||
{}
|
||||
(db/exec! conn ["select * from server_prop;"])))
|
||||
|
||||
(defn- initialize
|
||||
[{:keys [pool] :as cfg}]
|
||||
(db/with-atomic [conn pool]
|
||||
(let [cfg (assoc cfg :conn conn)]
|
||||
(initialize-secret-key cfg)
|
||||
(initialize-instance-id cfg)
|
||||
(retrieve-all cfg))))
|
|
@ -115,7 +115,7 @@
|
|||
:fullname (str "Profile " i)
|
||||
:email (str "profile" i ".test@nodomain.com")
|
||||
:password "123123"
|
||||
:demo? true}]
|
||||
:is-demo true}]
|
||||
(->> (#'profile/create-profile conn params)
|
||||
(#'profile/create-profile-relations conn))))
|
||||
|
||||
|
@ -159,7 +159,7 @@
|
|||
:fullname (str "Profile " i)
|
||||
:email (str "profile" i ".test@nodomain.com")
|
||||
:password "123123"
|
||||
:demo? false}
|
||||
:is-demo false}
|
||||
params)]
|
||||
(->> (#'profile/create-profile conn params)
|
||||
(#'profile/create-profile-relations conn)))))
|
||||
|
|
Loading…
Reference in a new issue