This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # announcements (5)
- # aws (16)
- # beginners (62)
- # calva (2)
- # cljdoc (17)
- # cljs-dev (2)
- # clojure (89)
- # clojure-brasil (1)
- # clojure-europe (3)
- # clojure-italy (12)
- # clojure-nl (1)
- # clojure-russia (2)
- # clojure-spec (10)
- # clojure-uk (26)
- # clojurescript (45)
- # cursive (4)
- # data-science (6)
- # datavis (1)
- # datomic (15)
- # duct (5)
- # fulcro (55)
- # juxt (1)
- # kaocha (2)
- # leiningen (1)
- # off-topic (101)
- # pathom (12)
- # portkey (4)
- # quil (5)
- # re-frame (9)
- # reagent (2)
- # reitit (28)
- # shadow-cljs (114)
- # spacemacs (9)
- # speculative (2)
- # sql (3)
- # test-check (18)
and everyone, feel free to contribute to docs, if something is written poorly or missing.
Is there a way (frontend) to prevent a route from “executing” and redirecting to an other route. I’d like to redirect to a login-component if not authenticated or if the user has the wrong role. Is that possible? I was experimenting with route data and controllers but don’t know how to redirect.
@defa My experience is that is better to keep authentication outside of routing. For rendering something like
(if authenticated [routing-view] [login-view]) and for controllers, only enable them after user is authenticated or something.
This way after authentication is done, user is at the correct route by default, and you don't need to redirect user back to previous view after login.
And you can enhance this to take into account views that don't need authentication via route-data:
(if (or authenticated (:public route-data)) [routing-view] [login-view])
@juhoteperi you’re right, that seems to be much simpler than having a dedicated route for a login panel.
@juhoteperi Thank you very much. An example would be a good nice for beginners. Took me a while to find #reitit as an alternative to secretary which seems to be pretty basic.
@kanwei reitit keeps the routes in order. For conflicting route tree, a
:qurantine-router is created, which runs all the conflicting routes with
:linear-router, so they are matched in order.
the router vector. you can ask the routes with
r/routes. with ring, it’s
(-> app reitit.ring/get-router reitit.core/routes)
if you have 1000 routes with 2 conflicts, the 998 (non-conflicting) will be as fast as route table with 998 without conflicts.
the 2 will be matched in order with a compiled Trie, so 99% as fast without conflicts.
just benchmarking the next
:trie-router which will replace the
:segment-router and it’s 20-40% faster.