From 2840cb893e0b129fd62bb6824194c05642f40222 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 22 Dec 2022 16:28:06 +0100 Subject: [PATCH] :tada: Add login-with-password flag As replacement to `login` flag --- backend/scripts/repl | 2 +- backend/scripts/start-dev | 2 +- backend/src/app/rpc/commands/auth.clj | 3 ++- common/src/app/common/flags.cljc | 3 +-- frontend/src/app/main/ui/auth/login.cljs | 8 ++++++-- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/backend/scripts/repl b/backend/scripts/repl index e6b3c6f24..3fe39461b 100755 --- a/backend/scripts/repl +++ b/backend/scripts/repl @@ -2,7 +2,7 @@ export PENPOT_HOST=devenv export PENPOT_TENANT=dev -export PENPOT_FLAGS="$PENPOT_FLAGS enable-backend-asserts enable-audit-log enable-transit-readable-response enable-demo-users disable-secure-session-cookies enable-smtp" +export PENPOT_FLAGS="$PENPOT_FLAGS enable-backend-asserts enable-audit-log enable-transit-readable-response enable-demo-users disable-secure-session-cookies enable-smtp enable-webhooks" # export PENPOT_DATABASE_URI="postgresql://172.17.0.1:5432/penpot" # export PENPOT_DATABASE_USERNAME="penpot" diff --git a/backend/scripts/start-dev b/backend/scripts/start-dev index d49c7c137..86edb2d70 100755 --- a/backend/scripts/start-dev +++ b/backend/scripts/start-dev @@ -2,7 +2,7 @@ export PENPOT_HOST=devenv export PENPOT_TENANT=dev -export PENPOT_FLAGS="$PENPOT_FLAGS enable-backend-asserts enable-audit-log enable-transit-readable-response enable-demo-users disable-secure-session-cookies enable-smtp" +export PENPOT_FLAGS="$PENPOT_FLAGS enable-backend-asserts enable-audit-log enable-transit-readable-response enable-demo-users disable-secure-session-cookies enable-smtp enable-webhooks" set -ex diff --git a/backend/src/app/rpc/commands/auth.clj b/backend/src/app/rpc/commands/auth.clj index 49da384bb..894e98179 100644 --- a/backend/src/app/rpc/commands/auth.clj +++ b/backend/src/app/rpc/commands/auth.clj @@ -71,7 +71,8 @@ (defn login-with-password [{:keys [::db/pool session] :as cfg} {:keys [email password scope] :as params}] - (when-not (contains? cf/flags :login) + (when-not (or (contains? cf/flags :login) + (contains? cf/flags :login-with-password)) (ex/raise :type :restriction :code :login-disabled :hint "login is disabled in this instance")) diff --git a/common/src/app/common/flags.cljc b/common/src/app/common/flags.cljc index 4cde8026e..bda243320 100644 --- a/common/src/app/common/flags.cljc +++ b/common/src/app/common/flags.cljc @@ -12,8 +12,7 @@ (def default "A common flags that affects both: backend and frontend." [:enable-registration - :enable-login - :enable-webhooks]) + :enable-login-with-password]) (defn parse [& flags] diff --git a/frontend/src/app/main/ui/auth/login.cljs b/frontend/src/app/main/ui/auth/login.cljs index a302697c1..583520c5f 100644 --- a/frontend/src/app/main/ui/auth/login.cljs +++ b/frontend/src/app/main/ui/auth/login.cljs @@ -171,7 +171,8 @@ :label (tr "auth.password")}]] [:div.buttons-stack - (when (contains? @cf/flags :login) + (when (or (contains? @cf/flags :login) + (contains? @cf/flags :login-with-password)) [:& fm/submit-button {:label (tr "auth.login-submit") :data-test "login-submit"}]) @@ -232,6 +233,7 @@ [:& login-buttons {:params params}] (when (or (contains? @cf/flags :login) + (contains? @cf/flags :login-with-password) (contains? @cf/flags :login-with-ldap)) [:span.separator [:span.line] @@ -239,6 +241,7 @@ [:span.line]])]) (when (or (contains? @cf/flags :login) + (contains? @cf/flags :login-with-password) (contains? @cf/flags :login-with-ldap)) [:& login-form {:params params :on-success-callback on-success-callback}])]) @@ -251,7 +254,8 @@ [:& login-methods {:params params}] [:div.links - (when (contains? @cf/flags :login) + (when (or (contains? @cf/flags :login) + (contains? @cf/flags :login-with-password)) [:div.link-entry [:& lk/link {:action #(st/emit! (rt/nav :auth-recovery-request)) :data-test "forgot-password"}