From 62a67bdb941f9f9757d6394ef1ed87ab16d12ec8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Moya?= Date: Tue, 25 Jan 2022 16:11:53 +0100 Subject: [PATCH 1/2] :tada: Set a domain cookie to check for logged from landing page --- backend/src/app/config.clj | 2 ++ backend/src/app/http/session.clj | 42 +++++++++++++++++++++++--------- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/backend/src/app/config.clj b/backend/src/app/config.clj index 5ca1574f5..b0030a2d1 100644 --- a/backend/src/app/config.clj +++ b/backend/src/app/config.clj @@ -109,6 +109,7 @@ (s/def ::secret-key ::us/string) (s/def ::allow-demo-users ::us/boolean) (s/def ::assets-path ::us/string) +(s/def ::authenticated-cookie-domain ::us/string) (s/def ::database-password (s/nilable ::us/string)) (s/def ::database-uri ::us/string) (s/def ::database-username (s/nilable ::us/string)) @@ -199,6 +200,7 @@ ::allow-demo-users ::audit-log-archive-uri ::audit-log-gc-max-age + ::authenticated-cookie-domain ::database-password ::database-uri ::database-username diff --git a/backend/src/app/http/session.clj b/backend/src/app/http/session.clj index 08abfe6e0..94e37219b 100644 --- a/backend/src/app/http/session.clj +++ b/backend/src/app/http/session.clj @@ -21,9 +21,13 @@ [integrant.core :as ig] [ring.middleware.session.store :as rss])) -;; A default cookie name for storing the session. We don't allow -;; configure it. -(def cookie-name "auth-token") +;; A default cookie name for storing the session. We don't allow to configure it. +(def token-cookie-name "auth-token") + +;; A cookie that we can use to check from other sites of the same domain if a user +;; is registered. Is not intended for on premise installations, although nothing +;; prevents using it if some one wants to. +(def authenticated-cookie-name "authenticated") (deftype DatabaseStore [pool tokens] rss/SessionStore @@ -78,7 +82,7 @@ (defn- delete-session [store {:keys [cookies] :as request}] - (when-let [token (get-in cookies [cookie-name :value])] + (when-let [token (get-in cookies [token-cookie-name :value])] (rss/delete-session store token))) (defn- retrieve-session @@ -88,21 +92,35 @@ (defn- retrieve-from-request [store {:keys [cookies] :as request}] - (->> (get-in cookies [cookie-name :value]) + (->> (get-in cookies [token-cookie-name :value]) (retrieve-session store))) (defn- add-cookies [response token] (let [cors? (contains? cfg/flags :cors) - secure? (contains? cfg/flags :secure-session-cookies)] - (assoc response :cookies {cookie-name {:path "/" - :http-only true - :value token - :same-site (if cors? :none :lax) - :secure secure?}}))) + secure? (contains? cfg/flags :secure-session-cookies) + authenticated-cookie-domain (cfg/get :authenticated-cookie-domain)] + (update response :cookies + (fn [cookies] + (cond-> cookies + :always + (assoc token-cookie-name {:path "/" + :http-only true + :value token + :same-site (if cors? :none :lax) + :secure secure?}) + + (some? authenticated-cookie-domain) + (assoc authenticated-cookie-name {:domain authenticated-cookie-domain + :path "/" + :value true + :same-site :strict + :secure secure?})))))) + (defn- clear-cookies [response] - (assoc response :cookies {cookie-name {:value "" :max-age -1}})) + (assoc response :cookies {token-cookie-name {:value "" :max-age -1} + authenticated-cookie-name {:value "" :max-age -1}})) (defn- middleware [events-ch store handler] From c5c331ee30a81c3b8ccaf1cdfe4ff930ac8fa700 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Moya?= Date: Wed, 9 Feb 2022 11:05:25 +0100 Subject: [PATCH 2/2] :sparkles: Refactor user menu in dashboard --- frontend/resources/images/icons/help.svg | 4 +++ .../main/partials/dashboard-sidebar.scss | 2 +- .../src/app/main/ui/dashboard/sidebar.cljs | 32 ++++++++++++------- frontend/src/app/main/ui/icons.cljs | 1 + .../src/app/main/ui/workspace/header.cljs | 1 - frontend/translations/en.po | 18 ++++++++++- frontend/translations/es.po | 18 ++++++++++- 7 files changed, 60 insertions(+), 16 deletions(-) create mode 100644 frontend/resources/images/icons/help.svg diff --git a/frontend/resources/images/icons/help.svg b/frontend/resources/images/icons/help.svg new file mode 100644 index 000000000..b1cb21827 --- /dev/null +++ b/frontend/resources/images/icons/help.svg @@ -0,0 +1,4 @@ + + + + diff --git a/frontend/resources/styles/main/partials/dashboard-sidebar.scss b/frontend/resources/styles/main/partials/dashboard-sidebar.scss index 0003951f4..b3d37d1a2 100644 --- a/frontend/resources/styles/main/partials/dashboard-sidebar.scss +++ b/frontend/resources/styles/main/partials/dashboard-sidebar.scss @@ -415,7 +415,7 @@ width: 12px; } - &.feedback { + &.separator { border-top: 1px solid $color-gray-10; } } diff --git a/frontend/src/app/main/ui/dashboard/sidebar.cljs b/frontend/src/app/main/ui/dashboard/sidebar.cljs index 5f0c3f715..46544b87d 100644 --- a/frontend/src/app/main/ui/dashboard/sidebar.cljs +++ b/frontend/src/app/main/ui/dashboard/sidebar.cljs @@ -513,22 +513,30 @@ [:li {:on-click (partial on-click :settings-profile) :data-test "profile-profile-opt"} [:span.icon i/user] - [:span.text (tr "labels.profile")]] - [:li {:on-click (partial on-click :settings-password) - :data-test "password-profile-opt"} - [:span.icon i/lock] - [:span.text (tr "labels.password")]] - [:li {:on-click #(on-click (du/logout) %) - :data-test "logout-profile-opt"} - [:span.icon i/exit] - [:span.text (tr "labels.logout")]] + [:span.text (tr "labels.your-account")]] + [:li.separator {:on-click #(dom/open-new-window "https://help.penpot.app") + :data-test "help-center-profile-opt"} + [:span.icon i/help] + [:span.text (tr "labels.help-center")]] + [:li {:on-click #(dom/open-new-window "https://penpot.app/libraries-templates.html") + :data-test "libraries-templates-profile-opt"} + [:span.icon i/download] + [:span.text (tr "labels.libraries-and-templates")]] + [:li {:on-click #(dom/open-new-window "https://penpot.app?no-redirect=1") + :data-test "about-penpot-profile-opt"} ;; Parameter ?no-redirect is to force stay in landing page + [:span.icon i/logo-icon] ;; instead of redirecting to app + [:span.text (tr "labels.about-penpot")]] (when (contains? @cf/flags :user-feedback) - [:li.feedback {:on-click (partial on-click :settings-feedback) + [:li.separator {:on-click (partial on-click :settings-feedback) :data-test "feedback-profile-opt"} [:span.icon i/msg-info] - [:span.text (tr "labels.give-feedback")] - ])]]] + [:span.text (tr "labels.give-feedback")]]) + + [:li.separator {:on-click #(on-click (du/logout) %) + :data-test "logout-profile-opt"} + [:span.icon i/exit] + [:span.text (tr "labels.logout")]]]]] (when (and team profile) [:& comments-section {:profile profile diff --git a/frontend/src/app/main/ui/icons.cljs b/frontend/src/app/main/ui/icons.cljs index 0230fa055..e2d61a77b 100644 --- a/frontend/src/app/main/ui/icons.cljs +++ b/frontend/src/app/main/ui/icons.cljs @@ -64,6 +64,7 @@ (def full-screen-off (icon-xref :full-screen-off)) (def grid (icon-xref :grid)) (def grid-snap (icon-xref :grid-snap)) +(def help (icon-xref :help)) (def icon-empty (icon-xref :icon-empty)) (def icon-list (icon-xref :icon-list)) (def icon-lock (icon-xref :icon-lock)) diff --git a/frontend/src/app/main/ui/workspace/header.cljs b/frontend/src/app/main/ui/workspace/header.cljs index a98c4051d..a42f5d163 100644 --- a/frontend/src/app/main/ui/workspace/header.cljs +++ b/frontend/src/app/main/ui/workspace/header.cljs @@ -241,7 +241,6 @@ [:span (tr "workspace.header.menu.option.preferences")] [:span i/arrow-slide]] (when (contains? @cf/flags :user-feedback) [:* - [:li.separator] [:li.feedback {:on-click (st/emitf (rt/nav :settings-feedback))} [:span (tr "labels.give-feedback")]]])]] diff --git a/frontend/translations/en.po b/frontend/translations/en.po index af9ea76fd..5d0e1a085 100644 --- a/frontend/translations/en.po +++ b/frontend/translations/en.po @@ -973,6 +973,10 @@ msgstr "Info" msgid "history.alert-message" msgstr "You are seeing version %s" +#: src/app/main/ui/dashboard/sidebar.cljs +msgid "labels.about-penpot" +msgstr "About Penpot" + msgid "labels.accept" msgstr "Accept" @@ -1108,6 +1112,10 @@ msgstr "Give feedback" msgid "labels.go-back" msgstr "Go back" +#: src/app/main/ui/dashboard/sidebar.cljs +msgid "labels.help-center" +msgstr "Help Center" + #: src/app/main/ui/workspace/comments.cljs, src/app/main/ui/viewer/header.cljs msgid "labels.hide-resolved-comments" msgstr "Hide resolved comments" @@ -1135,6 +1143,10 @@ msgstr "Internal Error" msgid "labels.language" msgstr "Language" +#: src/app/main/ui/dashboard/sidebar.cljs +msgid "labels.libraries-and-templates" +msgstr "Libraries & Templates" + msgid "labels.link" msgstr "Link" @@ -1216,7 +1228,7 @@ msgstr "Password" msgid "labels.permissions" msgstr "Permissions" -#: src/app/main/ui/settings/sidebar.cljs, src/app/main/ui/dashboard/sidebar.cljs +#: src/app/main/ui/settings/sidebar.cljs msgid "labels.profile" msgstr "Profile" @@ -1330,6 +1342,10 @@ msgstr "Workspace" msgid "labels.write-new-comment" msgstr "Write new comment" +#: src/app/main/ui/dashboard/sidebar.cljs +msgid "labels.your-account" +msgstr "Your account" + #: src/app/main/data/workspace/persistence.cljs, src/app/main/data/workspace/persistence.cljs, src/app/main/data/media.cljs msgid "media.loading" msgstr "Loading image…" diff --git a/frontend/translations/es.po b/frontend/translations/es.po index 9b7d2e16d..c9df35e38 100644 --- a/frontend/translations/es.po +++ b/frontend/translations/es.po @@ -974,6 +974,10 @@ msgstr "Información" msgid "history.alert-message" msgstr "Estás viendo la versión %s" +#: src/app/main/ui/dashboard/sidebar.cljs +msgid "labels.about-penpot" +msgstr "Acerca de Penpot" + msgid "labels.accept" msgstr "Aceptar" @@ -1109,6 +1113,10 @@ msgstr "Danos tu opinión" msgid "labels.go-back" msgstr "Volver" +#: src/app/main/ui/dashboard/sidebar.cljs +msgid "labels.help-center" +msgstr "Centro de ayuda" + #: src/app/main/ui/workspace/comments.cljs, src/app/main/ui/viewer/header.cljs msgid "labels.hide-resolved-comments" msgstr "Ocultar comentarios resueltos" @@ -1136,6 +1144,10 @@ msgstr "Error interno" msgid "labels.language" msgstr "Idioma" +#: src/app/main/ui/dashboard/sidebar.cljs +msgid "labels.libraries-and-templates" +msgstr "Bibliotecas y Plantillas" + msgid "labels.link" msgstr "Enlace" @@ -1217,7 +1229,7 @@ msgstr "Contraseña" msgid "labels.permissions" msgstr "Permisos" -#: src/app/main/ui/settings/sidebar.cljs, src/app/main/ui/dashboard/sidebar.cljs +#: src/app/main/ui/settings/sidebar.cljs msgid "labels.profile" msgstr "Perfil" @@ -1332,6 +1344,10 @@ msgstr "Espacio de trabajo" msgid "labels.write-new-comment" msgstr "Escribir un nuevo comentario" +#: src/app/main/ui/dashboard/sidebar.cljs +msgid "labels.your-account" +msgstr "Tu cuenta" + #: src/app/main/data/workspace/persistence.cljs, src/app/main/data/workspace/persistence.cljs, src/app/main/data/media.cljs msgid "media.loading" msgstr "Cargando imagen…"