From 688d649c4aa615f6484fbd864e926731294c760e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Moya?= Date: Mon, 22 Feb 2021 17:11:51 +0100 Subject: [PATCH] :bug: Hide registration screen when registration is disabled --- CHANGES.md | 1 + docker/images/files/config.js | 1 + docker/images/files/nginx-entrypoint.sh | 11 +++++++++ frontend/resources/locales.json | 2 +- frontend/src/app/config.cljs | 31 ++++++++++++------------ frontend/src/app/main/ui.cljs | 6 +++-- frontend/src/app/main/ui/auth/login.cljs | 11 +++++---- 7 files changed, 40 insertions(+), 23 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index d0fc67314d..67da4a1b45 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -27,6 +27,7 @@ - Properly handle errors on github, gitlab and ldap auth backends. - Properly mark profile auth backend (on first register/ auth with 3rd party auth provider). - Refactor LDAP auth backend. +- Hide register screen when registration is disabled [#598](https://github.com/penpot/penpot/issues/598) ### :heart: Community contributions by (Thank you!) diff --git a/docker/images/files/config.js b/docker/images/files/config.js index 6211080733..0ac491bbb8 100644 --- a/docker/images/files/config.js +++ b/docker/images/files/config.js @@ -7,3 +7,4 @@ //var penpotGitlabClientID = ""; //var penpotGithubClientID = ""; //var penpotLoginWithLDAP = ; +//var penpotRegistrationEnabled = ; diff --git a/docker/images/files/nginx-entrypoint.sh b/docker/images/files/nginx-entrypoint.sh index 6c0a428f51..e99e697872 100644 --- a/docker/images/files/nginx-entrypoint.sh +++ b/docker/images/files/nginx-entrypoint.sh @@ -79,6 +79,16 @@ update_login_with_ldap() { fi } + +update_registration_enabled() { + if [ -n "$PENPOT_REGISTRATION_ENABLED" ]; then + log "Updating Registration Enabled: $PENPOT_REGISTRATION_ENABLED" + sed -i \ + -e "s|^//var penpotRegistrationEnabled = .*;|var penpotRegistrationEnabled = $PENPOT_REGISTRATION_ENABLED;|g" \ + "$1" + fi +} + update_public_uri /var/www/app/js/config.js update_demo_warning /var/www/app/js/config.js update_allow_demo_users /var/www/app/js/config.js @@ -86,5 +96,6 @@ update_google_client_id /var/www/app/js/config.js update_gitlab_client_id /var/www/app/js/config.js update_github_client_id /var/www/app/js/config.js update_login_with_ldap /var/www/app/js/config.js +update_registration_enabled /var/www/app/js/config.js exec "$@"; diff --git a/frontend/resources/locales.json b/frontend/resources/locales.json index 31d53c4c3b..2ac41bc0c4 100644 --- a/frontend/resources/locales.json +++ b/frontend/resources/locales.json @@ -34,7 +34,7 @@ "translations" : { "ca" : "Crea un compte de proba", "en" : "Create demo account", - "es" : "Crear cuanta de prueba", + "es" : "Crear cuenta de prueba", "fr" : "Créer un compte de démonstration", "ru" : "Хотите попробовать?", "zh_cn" : "创建演示账号" diff --git a/frontend/src/app/config.cljs b/frontend/src/app/config.cljs index 70e808686c..be85ce6d2f 100644 --- a/frontend/src/app/config.cljs +++ b/frontend/src/app/config.cljs @@ -66,23 +66,24 @@ (def default-theme "default") (def default-language "en") -(def demo-warning (obj/get global "penpotDemoWarning" false)) -(def feedback-enabled (obj/get global "penpotFeedbackEnabled" false)) -(def allow-demo-users (obj/get global "penpotAllowDemoUsers" true)) -(def google-client-id (obj/get global "penpotGoogleClientID" nil)) -(def gitlab-client-id (obj/get global "penpotGitlabClientID" nil)) -(def github-client-id (obj/get global "penpotGithubClientID" nil)) -(def login-with-ldap (obj/get global "penpotLoginWithLDAP" false)) -(def worker-uri (obj/get global "penpotWorkerURI" "/js/worker.js")) -(def translations (obj/get global "penpotTranslations")) -(def themes (obj/get global "penpotThemes")) +(def demo-warning (obj/get global "penpotDemoWarning" false)) +(def feedback-enabled (obj/get global "penpotFeedbackEnabled" false)) +(def allow-demo-users (obj/get global "penpotAllowDemoUsers" true)) +(def google-client-id (obj/get global "penpotGoogleClientID" nil)) +(def gitlab-client-id (obj/get global "penpotGitlabClientID" nil)) +(def github-client-id (obj/get global "penpotGithubClientID" nil)) +(def login-with-ldap (obj/get global "penpotLoginWithLDAP" false)) +(def registration-enabled (obj/get global "penpotRegistrationEnabled" true)) +(def worker-uri (obj/get global "penpotWorkerURI" "/js/worker.js")) +(def translations (obj/get global "penpotTranslations")) +(def themes (obj/get global "penpotThemes")) -(def public-uri (or (obj/get global "penpotPublicURI") (.-origin ^js location))) +(def public-uri (or (obj/get global "penpotPublicURI") (.-origin ^js location))) -(def version (delay (parse-version global))) -(def target (delay (parse-target global))) -(def browser (delay (parse-browser))) -(def platform (delay (parse-platform))) +(def version (delay (parse-version global))) +(def target (delay (parse-target global))) +(def browser (delay (parse-browser))) +(def platform (delay (parse-platform))) (when (= :browser @target) (js/console.log diff --git a/frontend/src/app/main/ui.cljs b/frontend/src/app/main/ui.cljs index 81ac15d54e..fb5861ec0d 100644 --- a/frontend/src/app/main/ui.cljs +++ b/frontend/src/app/main/ui.cljs @@ -60,8 +60,10 @@ (def routes [["/auth" ["/login" :auth-login] - ["/register" :auth-register] - ["/register/success" :auth-register-success] + (when cfg/registration-enabled + ["/register" :auth-register]) + (when cfg/registration-enabled + ["/register/success" :auth-register-success]) ["/recovery/request" :auth-recovery-request] ["/recovery" :auth-recovery] ["/verify-token" :auth-verify-token]] diff --git a/frontend/src/app/main/ui/auth/login.cljs b/frontend/src/app/main/ui/auth/login.cljs index 15b663531e..db3b56cf76 100644 --- a/frontend/src/app/main/ui/auth/login.cljs +++ b/frontend/src/app/main/ui/auth/login.cljs @@ -145,11 +145,12 @@ :tab-index "5"} (tr "auth.forgot-password")]] - [:div.link-entry - [:span (tr "auth.register") " "] - [:a {:on-click #(st/emit! (rt/nav :auth-register {} params)) - :tab-index "6"} - (tr "auth.register-submit")]]] + (when cfg/registration-enabled + [:div.link-entry + [:span (tr "auth.register") " "] + [:a {:on-click #(st/emit! (rt/nav :auth-register {} params)) + :tab-index "6"} + (tr "auth.register-submit")]])] (when cfg/google-client-id [:a.btn-ocean.btn-large.btn-google-auth