Fork me on GitHub
#fulcro
<
2020-10-22
>
magra09:10:26

What would be a good approach to (rarely) upload a pdf from a fulcro app to the server when I use fulcro-websocket remote? The upload-file namespace needs http-remote. Are there writers to serialize and where would I plug them in and what format would make sense? Or do I register a second remote as http-remote to the same server for uploads since uploads will happen only rarely?

bbss09:10:46

@magra I'd go for the second option, you could use the examples for a file upload remote and not have to adjust it much.

šŸ™ 3
njj13:10:29

Has anyone had any success using https://github.com/cemerick/friend w/ http-kit and fulcro3?

tvaughan15:10:56

We chose buddy, and we're happy with it

šŸ‘ 3
njj19:10:21

@U0P7ZBZCK do you have it thread in the middleware or where did you place it? Iā€™m looking at some of their examples and trying to figure out where it would fit

tvaughan19:10:46

(defn- auth-required?
  [segment]
  ;; `accounts` and `static` are used to render the signin page, and `sessions`
  ;; is the API endpoint used to authenticate users and create sessions.
  (not-in? segment ["accounts" "static" "sessions"]))

(defn- check-auth-required
  [handler]
  (fn [request]
    (let [segment (nth (str/split (:uri request) #"/" 3) 1)]
      (if (and (auth-required? segment) (not (authenticated? request)))
        (if (in? segment ["api" "static"])
          (response/unauthorized)
          (response/found (urls/route->url (dr/path-to ui/SignIn))))
        (handler request)))))

(defonce ^:private session-auth-backend (backends/session))

(defn wrap-check-auth-required
  [handler {:keys [session-secret]}]
  (-> handler
      check-auth-required
      (wrap-authentication session-auth-backend)
      (wrap-session {:store (cookie-store {:key (s->bytes session-secret)})
                     :cookie-attrs {:http-only true :same-site :strict}})))

tvaughan19:10:22

middelware

šŸ‘ 3
tvaughan19:10:08

No problem. I hope it's helpful