Fix bug caused by stale session
* in case API AJAX calls start failing, make sure user is logged out to avoid frontend being in a corrupt state
This commit is contained in:
parent
f932b3705d
commit
32392a4405
|
@ -29,8 +29,7 @@
|
|||
(when-let [[type message] @flash-message]
|
||||
[:div.flash-message {:class (name type)}
|
||||
[:i.close.icon {:on-click #(rf/dispatch [:clear-flash-message])}]
|
||||
[:p message]]))
|
||||
))
|
||||
[:p message]]))))
|
||||
|
||||
(def user-dropdown-open? (r/atom false))
|
||||
|
||||
|
@ -112,7 +111,6 @@
|
|||
:update-address #'update-address-page})
|
||||
|
||||
|
||||
|
||||
(defn top-hunters []
|
||||
(let [top-hunters (rf/subscribe [:top-hunters])]
|
||||
(fn []
|
||||
|
@ -181,6 +179,7 @@
|
|||
(rf/dispatch [:load-bounties]))
|
||||
|
||||
(defn load-data []
|
||||
(println "load-data")
|
||||
(load-issues)
|
||||
(load-user))
|
||||
|
||||
|
|
|
@ -19,11 +19,17 @@
|
|||
(js/setTimeout #(dispatch args)
|
||||
timeout)))
|
||||
|
||||
(reg-fx
|
||||
:redirect
|
||||
(fn [{:keys [path]}]
|
||||
(println "redirecting to" path)
|
||||
(set! (.-pathname js/location) path))
|
||||
|
||||
|
||||
(reg-event-db
|
||||
:initialize-db
|
||||
(fn [_ _]
|
||||
db/default-db))
|
||||
db/default-db)))
|
||||
|
||||
(reg-event-db
|
||||
:assoc-in
|
||||
|
@ -65,16 +71,13 @@
|
|||
:set-active-user
|
||||
(fn [{:keys [db]} [_ user]]
|
||||
{:db (assoc db :user user)
|
||||
:dispatch-n [[:load-user-profile]
|
||||
[:load-user-repos]
|
||||
[:load-owner-bounties]]}))
|
||||
:dispatch [:load-user-profile]}))
|
||||
|
||||
(reg-event-fx
|
||||
:sign-out
|
||||
(fn [{:keys [db]} [_]]
|
||||
{:db (assoc db :user nil)
|
||||
:http {:method GET
|
||||
:url "/logout"}}))
|
||||
:redirect {:path "/logout"}}))
|
||||
|
||||
(reg-event-fx
|
||||
:load-bounties
|
||||
|
@ -118,12 +121,16 @@
|
|||
{:db db
|
||||
:http {:method GET
|
||||
:url "/api/user"
|
||||
:on-success #(dispatch [:set-user-profile %])}}))
|
||||
:on-success #(dispatch [:set-user-profile %])
|
||||
:on-error #(dispatch [:sign-out])}}))
|
||||
|
||||
(reg-event-db
|
||||
(reg-event-fx
|
||||
:set-user-profile
|
||||
(fn [db [_ user-profile]]
|
||||
(assoc db :user (:user user-profile))))
|
||||
(fn [{:keys [db]} [_ user-profile]]
|
||||
{:db
|
||||
(assoc db :user (:user user-profile))
|
||||
:dispatch-n [[:load-user-repos]
|
||||
[:load-owner-bounties]]}))
|
||||
|
||||
(reg-event-db
|
||||
:set-user-repos
|
||||
|
|
Loading…
Reference in New Issue