0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-26 00:19:07 -05:00

🐛 Fix error handling on verify-token page

This commit is contained in:
Andrey Antukh 2024-06-27 16:10:26 +02:00
parent c45a105186
commit 56160cf64d

View file

@ -70,27 +70,28 @@
(rx/subs! (rx/subs!
(fn [tdata] (fn [tdata]
(handle-token tdata)) (handle-token tdata))
(fn [{:keys [type code] :as error}] (fn [cause]
(cond (let [{:keys [type code] :as error} (ex-data cause)]
(or (= :validation type) (cond
(= :invalid-token code) (or (= :validation type)
(= :token-expired (:reason error))) (= :invalid-token code)
(reset! bad-token true) (= :token-expired (:reason error)))
(reset! bad-token true)
(= :email-already-exists code) (= :email-already-exists code)
(let [msg (tr "errors.email-already-exists")] (let [msg (tr "errors.email-already-exists")]
(ts/schedule 100 #(st/emit! (msg/error msg))) (ts/schedule 100 #(st/emit! (msg/error msg)))
(st/emit! (rt/nav :auth-login))) (st/emit! (rt/nav :auth-login)))
(= :email-already-validated code) (= :email-already-validated code)
(let [msg (tr "errors.email-already-validated")] (let [msg (tr "errors.email-already-validated")]
(ts/schedule 100 #(st/emit! (msg/warn msg))) (ts/schedule 100 #(st/emit! (msg/warn msg)))
(st/emit! (rt/nav :auth-login))) (st/emit! (rt/nav :auth-login)))
:else :else
(let [msg (tr "errors.generic")] (let [msg (tr "errors.generic")]
(ts/schedule 100 #(st/emit! (msg/error msg))) (ts/schedule 100 #(st/emit! (msg/error msg)))
(st/emit! (rt/nav :auth-login)))))))) (st/emit! (rt/nav :auth-login)))))))))
(if @bad-token (if @bad-token
[:> static/invalid-token {}] [:> static/invalid-token {}]