Add a callback-url parameter to login (#8655)

This commit is contained in:
Pablo Alba 2026-03-18 10:15:31 +01:00 committed by GitHub
parent 5482ee211e
commit 04a3e236fe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -46,12 +46,12 @@
(st/emit! (da/create-demo-profile))) (st/emit! (da/create-demo-profile)))
(defn- store-login-redirect (defn- store-login-redirect
[] [callback-url]
(binding [s/*sync* true] (binding [s/*sync* true]
;; Save the current login raw uri for later redirect user back to ;; Save the current login raw uri for later redirect user back to
;; the same page, we need it to be synchronous because the user is ;; the same page, we need it to be synchronous because the user is
;; going to be redirected instantly to the oidc provider uri ;; going to be redirected instantly to the oidc provider uri
(swap! s/session assoc :login-redirect (rt/get-current-href)))) (swap! s/session assoc :login-redirect (or callback-url (rt/get-current-href)))))
(defn- clear-login-redirect (defn- clear-login-redirect
[] []
@ -76,6 +76,7 @@
error (mf/use-state false) error (mf/use-state false)
form (fm/use-form :schema schema:login-form form (fm/use-form :schema schema:login-form
:initial initial) :initial initial)
callback-url (:callback-url params)
on-error on-error
(fn [cause] (fn [cause]
(let [cause (ex-data cause)] (let [cause (ex-data cause)]
@ -158,9 +159,9 @@
#(st/emit! (rt/nav :auth-recovery-request)))] #(st/emit! (rt/nav :auth-recovery-request)))]
(mf/with-effect [handle-redirect] (mf/with-effect [handle-redirect callback-url]
(if handle-redirect (if (or handle-redirect callback-url)
(store-login-redirect) (store-login-redirect callback-url)
(clear-login-redirect))) (clear-login-redirect)))
[:* [:*