mirror of
https://github.com/penpot/penpot.git
synced 2025-06-01 02:02:14 +02:00
🐛 Avoid unexpected error when a cookie is expired.
This commit is contained in:
parent
7e020f967b
commit
8f37f74d29
2 changed files with 20 additions and 29 deletions
|
@ -51,20 +51,12 @@
|
||||||
|
|
||||||
(defn on-navigate
|
(defn on-navigate
|
||||||
[router path]
|
[router path]
|
||||||
(let [match (match-path router path)
|
(let [match (match-path router path)]
|
||||||
profile (:profile storage)
|
|
||||||
authed? (and (not (nil? profile))
|
|
||||||
(not= (:id profile) uuid/zero))]
|
|
||||||
|
|
||||||
(cond
|
(cond
|
||||||
(and (or (= path "")
|
(or (= path "")
|
||||||
(nil? match))
|
(nil? match))
|
||||||
(not authed?))
|
|
||||||
(st/emit! (rt/nav :auth-login))
|
(st/emit! (rt/nav :auth-login))
|
||||||
|
|
||||||
(and (nil? match) authed?)
|
|
||||||
(st/emit! (rt/nav :dashboard-projects {:team-id (:default-team-id profile)}))
|
|
||||||
|
|
||||||
(nil? match)
|
(nil? match)
|
||||||
(st/emit! (rt/nav :not-found))
|
(st/emit! (rt/nav :not-found))
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
(.replace js/location redirect-uri)))))
|
(.replace js/location redirect-uri)))))
|
||||||
|
|
||||||
(mf/defc login-form
|
(mf/defc login-form
|
||||||
[{:keys [locale] :as props}]
|
[]
|
||||||
(let [error? (mf/use-state false)
|
(let [error? (mf/use-state false)
|
||||||
form (fm/use-form :spec ::login-form
|
form (fm/use-form :spec ::login-form
|
||||||
:inital {})
|
:inital {})
|
||||||
|
@ -79,7 +79,7 @@
|
||||||
(when @error?
|
(when @error?
|
||||||
[:& msgs/inline-banner
|
[:& msgs/inline-banner
|
||||||
{:type :warning
|
{:type :warning
|
||||||
:content (t locale "errors.auth.unauthorized")
|
:content (tr "errors.auth.unauthorized")
|
||||||
:on-close #(reset! error? false)}])
|
:on-close #(reset! error? false)}])
|
||||||
|
|
||||||
[:& fm/form {:on-submit on-submit :form form}
|
[:& fm/form {:on-submit on-submit :form form}
|
||||||
|
@ -89,43 +89,42 @@
|
||||||
:type "text"
|
:type "text"
|
||||||
:tab-index "2"
|
:tab-index "2"
|
||||||
:help-icon i/at
|
:help-icon i/at
|
||||||
:label (t locale "auth.email")}]]
|
:label (tr "auth.email")}]]
|
||||||
[:div.fields-row
|
[:div.fields-row
|
||||||
[:& fm/input
|
[:& fm/input
|
||||||
{:type "password"
|
{:type "password"
|
||||||
:name :password
|
:name :password
|
||||||
:tab-index "3"
|
:tab-index "3"
|
||||||
:help-icon i/eye
|
:help-icon i/eye
|
||||||
:label (t locale "auth.password")}]]
|
:label (tr "auth.password")}]]
|
||||||
[:& fm/submit-button
|
[:& fm/submit-button
|
||||||
{:label (t locale "auth.login-submit")
|
{:label (tr "auth.login-submit")
|
||||||
:on-click on-submit}]
|
:on-click on-submit}]
|
||||||
(when cfg/login-with-ldap
|
(when cfg/login-with-ldap
|
||||||
[:& fm/submit-button
|
[:& fm/submit-button
|
||||||
{:label (t locale "auth.login-with-ldap-submit")
|
{:label (tr "auth.login-with-ldap-submit")
|
||||||
:on-click on-submit}])]]))
|
:on-click on-submit}])]]))
|
||||||
|
|
||||||
(mf/defc login-page
|
(mf/defc login-page
|
||||||
[{:keys [locale] :as props}]
|
[]
|
||||||
|
|
||||||
[:div.generic-form.login-form
|
[:div.generic-form.login-form
|
||||||
[:div.form-container
|
[:div.form-container
|
||||||
[:h1 (t locale "auth.login-title")]
|
[:h1 (tr "auth.login-title")]
|
||||||
[:div.subtitle (t locale "auth.login-subtitle")]
|
[:div.subtitle (tr "auth.login-subtitle")]
|
||||||
|
|
||||||
[:& login-form {:locale locale}]
|
[:& login-form {}]
|
||||||
|
|
||||||
[:div.links
|
[:div.links
|
||||||
[:div.link-entry
|
[:div.link-entry
|
||||||
[:a {:on-click #(st/emit! (rt/nav :auth-recovery-request))
|
[:a {:on-click #(st/emit! (rt/nav :auth-recovery-request))
|
||||||
:tab-index "5"}
|
:tab-index "5"}
|
||||||
(t locale "auth.forgot-password")]]
|
(tr "auth.forgot-password")]]
|
||||||
|
|
||||||
[:div.link-entry
|
[:div.link-entry
|
||||||
[:span (t locale "auth.register") " "]
|
[:span (tr "auth.register") " "]
|
||||||
[:a {:on-click #(st/emit! (rt/nav :auth-register))
|
[:a {:on-click #(st/emit! (rt/nav :auth-register))
|
||||||
:tab-index "6"}
|
:tab-index "6"}
|
||||||
(t locale "auth.register-submit")]]]
|
(tr "auth.register-submit")]]]
|
||||||
|
|
||||||
(when cfg/google-client-id
|
(when cfg/google-client-id
|
||||||
[:a.btn-ocean.btn-large.btn-google-auth
|
[:a.btn-ocean.btn-large.btn-google-auth
|
||||||
|
@ -137,11 +136,11 @@
|
||||||
{:on-click login-with-gitlab}
|
{:on-click login-with-gitlab}
|
||||||
[:img.logo
|
[:img.logo
|
||||||
{:src "/images/icons/brand-gitlab.svg"}]
|
{:src "/images/icons/brand-gitlab.svg"}]
|
||||||
(t locale "auth.login-with-gitlab-submit")])
|
(tr "auth.login-with-gitlab-submit")])
|
||||||
|
|
||||||
[:div.links.demo
|
[:div.links.demo
|
||||||
[:div.link-entry
|
[:div.link-entry
|
||||||
[:span (t locale "auth.create-demo-profile") " "]
|
[:span (tr "auth.create-demo-profile") " "]
|
||||||
[:a {:on-click #(st/emit! da/create-demo-profile)
|
[:a {:on-click (st/emitf da/create-demo-profile)
|
||||||
:tab-index "6"}
|
:tab-index "6"}
|
||||||
(t locale "auth.create-demo-account")]]]]])
|
(tr "auth.create-demo-account")]]]]])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue