You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What's a recommended way to build a login wall to a Secretary routed app? Currently I'm doing this up top on my routes namespace.
(defn enforce-login []
"Check authentication of user then redirect to login page if not"
(when-not (re-seq #"/#/login$" (.-href js/window.location)) ;; not at login page
(if-let [token (c/get-token)]
(go-authenticate token)
(.replace window.location "/#/login"))))
It sort of work but user can still jump into any route if they know the URL. I'm thinking I could wrap each route with a authorisation func first?
(defroute "/foo" [] (auth? (run-foo)))
That's basically a middleware.
Is there middleware for Secretary? If not, could you point me the right way to making one please?
The text was updated successfully, but these errors were encountered:
You could handle authentication before calling secretary/dispatch! on hash changes.
Is there middleware for Secretary?
No, not built in, but I think it's something worth considering for future versions. What we should probably do is allow secretary/dispatch! to take a handler function so this sort of thing is easier to do.
What's a recommended way to build a login wall to a Secretary routed app? Currently I'm doing this up top on my routes namespace.
It sort of work but user can still jump into any route if they know the URL. I'm thinking I could wrap each route with a authorisation func first?
That's basically a middleware.
Is there middleware for Secretary? If not, could you point me the right way to making one please?
The text was updated successfully, but these errors were encountered: