0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-20 19:51:23 -05:00

Add parameter to disable registration

This commit is contained in:
mathieu.brunot 2019-02-19 23:09:57 +01:00
parent 79f7d29df9
commit e8bd7436aa
No known key found for this signature in database
GPG key ID: 81584BEAF692D7E0
6 changed files with 14 additions and 2 deletions

View file

@ -56,6 +56,8 @@
:smtp-ssl (lookup-env env :uxbox-smtp-ssl false)
:smtp-enabled (lookup-env env :uxbox-smtp-enabled false)
:registration-enabled (lookup-env env :uxbox-registration-enabled true)
:secret (lookup-env env :uxbox-secret "5qjiAndGY3")})
(defn read-test-config

View file

@ -12,6 +12,7 @@
[buddy.sign.jwe :as jwe]
[uxbox.sql :as sql]
[uxbox.db :as db]
[uxbox.config :as cfg]
[uxbox.util.spec :as us]
[uxbox.emails :as emails]
[uxbox.services.core :as core]
@ -186,8 +187,11 @@
(defmethod core/novelty :register-profile
[params]
(s/assert ::register params)
(with-open [conn (db/connection)]
(sc/apply-atomic conn register-user params)))
(if (= (:registration-enabled config) true)
(with-open [conn (db/connection)]
(sc/apply-atomic conn register-user params))
(ex/raise :type :validation
:code ::registration-disabled)))
;; --- Password Recover

View file

@ -62,6 +62,7 @@
"history.alert-message" "You are seeing version %s"
"errors.api.form.old-password-not-match" "Incorrect old password"
"errors.api.form.registration-disabled" "The registration is currently disabled."
"errors.api.form.email-already-exists" "The email is already in use by another user."
"errors.api.form.username-already-exists" "The username is already in use by another user."
"errors.api.form.user-not-exists" "Username or email does not matches any existing user."

View file

@ -62,6 +62,7 @@
"history.alert-message" "Vous voyez la version %s"
"errors.api.form.old-password-not-match" "Ancien mot de passe incorrect"
"errors.api.form.registration-disabled" "L'enregistrement est actuellement désactivé."
"errors.api.form.email-already-exists" "L'email est déjà utilisé par un autre utilisateur."
"errors.api.form.username-already-exists" "Le nom d'utilisateur est déjà utilisé par un autre utilisateur."
"errors.api.form.user-not-exists" "Le nom d'utilisateur ou l'e-mail ne correspond à aucun utilisateur existant."

View file

@ -51,6 +51,8 @@
(st/emit! (assoc-value field value))))
(on-error [{:keys [type code] :as payload}]
(case code
:uxbox.services.users/registration-disabled
(st/emit! "Registration is disabled")
:uxbox.services.users/email-already-exists
(st/emit! (assoc-error :email "Email already exists"))
:uxbox.services.users/username-already-exists

View file

@ -59,6 +59,8 @@
(st/emit! (assoc-value field value))))
(on-error [{:keys [code] :as payload}]
(case code
:uxbox.services.users/registration-disabled
(st/emit! "Registration is disabled")
:uxbox.services.users/email-already-exists
(st/emit! (assoc-error :email "Email already exists"))
:uxbox.services.users/username-already-exists