This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-05-28
Channels
- # babashka (29)
- # beginners (179)
- # bristol-clojurians (1)
- # calva (9)
- # chlorine-clover (47)
- # cider (57)
- # clj-kondo (1)
- # cljs-dev (13)
- # clojure (241)
- # clojure-europe (9)
- # clojure-nl (4)
- # clojure-norway (88)
- # clojure-spec (4)
- # clojure-uk (15)
- # clojurescript (211)
- # clojutre (1)
- # community-development (8)
- # core-async (1)
- # datomic (31)
- # figwheel-main (33)
- # fulcro (29)
- # ghostwheel (6)
- # graalvm (11)
- # graphql (12)
- # instaparse (4)
- # jobs (1)
- # jobs-discuss (17)
- # leiningen (7)
- # malli (6)
- # meander (38)
- # off-topic (208)
- # onyx (6)
- # re-frame (23)
- # reagent (8)
- # shadow-cljs (61)
- # spacemacs (10)
- # sql (5)
- # yada (5)
I'm a bit stuck on fulcro-rad-demo again. How is it determined if a route can be accessed with or without authentication? It seems form/defsc-form
forms are by default only for logged in users? And how do I check for roles, or is that something that is not part of fulcro-rad's auth?
Auth is not fleshed out yet
Now in terms of how it is supposed to work: well, I can give you some basics: 1. Say you want to go to Report A, which queries for attributes x, y, and z. 2. The system should scan x, y, and z (the attribute definitions, which would contain auth lambdas or something) and ask the auth machine: “Does it make sense to allow this, and if not, can you ask the user for creds to make it ok?” 3. The auth machine would go about its work (full-stack, async, possibly with auth redirects that require saving state in brower local state), and eventually sends an event back to the router (or report SM…not sure): Yes or No.
so the basic idea is still attribute-centric, possibly with additional keys you could put on target component, that interacts with a pluggable auth state machine to both acquire authorization and authentication in order to see if a route “is legal at this time”
There’s also the problem of partial approval: the route is “ok”, but some of the attributes will need to be hidden or read only…
So, its a large task. Consider the auth in the demo to be a very very bare bones starting point, and not remotely close to the real solution.
And that real solution is currently beyond my real personal needs. I’m using the reports and forms to good effect in production. I don’t need the auth system.
and many apps can do with just a “block unless auth’d” approach like in the demo, with just a bit of code wrapping the routing for auth redirect.
So, short answer: Write your own landing page. Write your own auth. Record the target URL on start (where they wanted to go, and start RAD after they are logged in (at which point you can also update the URL to trigger a bookmark nav).
I'm getting a "FORM NOT NORMALIZED" error when trying to perform a transact!
and I'm struggling to understand why.
My form has an ident.
(defsc UserForm [this {,,,}]
{,,, :ident [::form ::user/id] ,,,}
The error prints out the form-config-path
as core.cljs:159 ERROR [com.fulcrologic.fulcro.algorithms.form-state:506] - FORM NOT NORMALIZED: [:com.scratchoff-odds.ui/form #uuid "8e7bc28b-bad7-4f74-bb74-9317fab270cb"]
My understanding is that it is normalized. That is a tuple of a table and id that uniquely identifies the form in the app state.
(get-in (app/current-state s.app/app)
[:com.scratchoff-odds.ui/form #uuid "8e7bc28b-bad7-4f74-bb74-9317fab270cb"])
;; => {:ui/errors {},
;; :com.scratchoff-odds.model.user/id
;; #uuid "8e7bc28b-bad7-4f74-bb74-9317fab270cb",
;; :com.scratchoff-odds.model.user/email "aset",
;; :com.scratchoff-odds.model.user/password "",
;; :com.fulcrologic.fulcro.algorithms.form-state/config
;; {:com.fulcrologic.fulcro.algorithms.form-state/complete?
;; #{:com.scratchoff-odds.model.user/email}}}
But mark-complete*
conjs that tuple with ::config
and checks eql/ident?
on that config, which doesn't look like it will ever be an ident.
(>defn mark-complete*
",,,"
(,,,
(let [form-config-path (conj entity-ident ::config)
form-config-path (if (eql/ident? (get-in state-map form-config-path))
(get-in state-map form-config-path)
(do
(js/console.log form-config-path)
(log/error (str "FORM NOT NORMALIZED: " entity-ident))
form-config-path))
Ok. I have a thread to pull on.
http://book.fulcrologic.com/#NetworkInteractionsandForms
Looking at the database in fulcro inspector for that example I see that the ::config
is different than mine. The value at form-config-path
for me is a map while the value at form-config-path
in that example is an ident.
Both my code and that example have similar-looking queries. [::some-attr ,,, fs/form-config-join]
.
But that example has an ident that matches the "model". The example uses :person/id
as an ident. I'm using an ident that's different from my "user" model table. I'm using [::form ::user/id]
rather than ::user/id
(or equilvalently [::user/id ::user/id]
.
I also see the example calls fs/add-form-config*
inside the mutation that initializes an "empty" new person object. I'll need to look into what that does.
(defmutation edit-new-person [_]
(action [{:keys [state]}]
(let [person-id (tempid/tempid)
person-ident [:person/id person-id]
phone-id (tempid/tempid)]
(swap! state
(fn [s] (-> s
(add-person* person-id "" 0)
(add-phone* phone-id person-id :home "")
(assoc :root/person person-ident) ; join it into the UI as the person to edit
(fs/add-form-config* PersonForm [:person/id person-id])))))))
@U0D5RN0S1 Ah. Sorry. Yes. Same result though. The path to form-config-path
still points to a value that is a map, not an ident.
when i've seen this in the past it was either not adding the form config or not joining the component properly:
Make sure you have joined your form to the parent component.
{:query [:my-thing/form]}
;; should be
{:query [{:my-thing/form (comp/get-query MyForm)}]}
I’ve got the same issue =)… Will look over your code later and see if we have any similarities…
When I run shadow-cljs on the rad-demo
project, and navigate to localhost:8081
the page that is server gives a console error main.js not found
. There is no compilation error on the shadow-cljs console, so why is the js file not being served ?
wrong port @murtaza52