This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-06-27
Channels
- # announcements (10)
- # aws (5)
- # babashka (91)
- # beginners (15)
- # biff (3)
- # calva (5)
- # clerk (24)
- # cljdoc (63)
- # clojure (69)
- # clojure-denver (1)
- # clojure-europe (13)
- # clojure-nl (1)
- # clojure-norway (50)
- # clojure-uk (2)
- # clojurescript (2)
- # community-development (6)
- # cursive (3)
- # datomic (4)
- # events (2)
- # fulcro (8)
- # gratitude (1)
- # hyperfiddle (19)
- # jobs-discuss (36)
- # nbb (21)
- # pathom (16)
- # portal (6)
- # re-frame (14)
- # reagent (1)
- # reitit (1)
- # releases (3)
- # remote-jobs (2)
- # shadow-cljs (56)
- # sql (15)
Hello, I am making a project that uses shadow-cljs, reitit, and firebase. I am now doing the routing for my navigation, and I wanted to see if what I am doing makes sense. I was thinking of authenticating my user before running the routes. If I do have a valid user, I will run the controllers for that route. If not, I will send them to the home page Does anyone have any comments about this? Any suggestions?
Define "running the routes." Do all routes require authorization? If so, then you can simply not call reitit.frontend.easy/start!
until you've authenticated a user
If some routes are public then you can conditionally call reitit.frontend.controllers/apply-controllers
when the URL is changing. The easiest way to implement is to first register a :route/navigated
event that applies controllers and is dispatched whenever routes change, then add an interceptor to this event that checks authentication status before the event handler runs, and provide some data indicating whether the user is authenticated or not.
I prefer to separate authentication and UI routing.
When a user makes any request to the server, the server checks for a session, for all non-public routes. If it's there - proceed as normal. If it's not - redirect to /login
with a breadcrumb that will let the server proceed as normal after the user provides the right credentials. Re-frame is not involved in the process at all.
So maybe the answer is just "don't use Strict Mode" but I started doing so and I noticed that it resets my app-db 😑 I'm guessing this happens bc of that double render. Is there a way around that?
strict mode should not interfere with this — assuming you’re using shadow-cljs, i would look at your after-load hooks, I guarantee one of them is dispatching some event that is not returning a copy of your app-db
IIRC reagent by default uses strict mode (at least when i used re-frame + react 17 the react devtools always showed i was using strict mode), so i dont think strict mode is a problem at all
Not according to react devtools at least, the little warning icon appears next to my root element saying it's not in strict mode
(If I turn it off myself that is)
I'll take a look at my hooks though, thanks
Hello everyone, I am using firebase in my project and I am doing my unit tests with karma. In one of my tests I want to add a user, which requires using the admin auth sdk. However, karma runs the tests in a browser environment but the auth sdk must be used in a node.js environment. A solution I was thinking of was to run the test in a separate file with a node.js environment. What would you guys recommend?
This seems to be better suited for #C03RZGPG3, no? Since it seems to be irrelevant not only to re-frame (where you're asking this question) but also to CLJS.