mirror of
https://github.com/penpot/penpot.git
synced 2026-07-01 20:05:26 +00:00
✨ Avoid going to last team on login if it is protected by sso (#10442)
This commit is contained in:
parent
5212e2202b
commit
a9f3949abc
@ -53,12 +53,16 @@
|
||||
:team-id (:default-team-id profile))
|
||||
(dp/update-profile-props {:welcome-file-id nil}))
|
||||
|
||||
(let [teams (into #{} (map :id) teams)
|
||||
team-id (dtm/get-last-team-id)
|
||||
team-id (if (and team-id (contains? teams team-id))
|
||||
team-id
|
||||
(:default-team-id profile))]
|
||||
(rx/of (dcm/go-to-dashboard-recent {:team-id team-id})))))))]
|
||||
(let [default-team-id (:default-team-id profile)
|
||||
team-ids (into #{} (map :id) teams)
|
||||
team-id (dtm/get-last-team-id)
|
||||
team-id (if (and team-id (contains? team-ids team-id))
|
||||
team-id
|
||||
default-team-id)]
|
||||
(->> (dtm/resolve-login-team-id {:team-id team-id
|
||||
:default-team-id default-team-id})
|
||||
(rx/mapcat (fn [team-id]
|
||||
(rx/of (dcm/go-to-dashboard-recent {:team-id team-id}))))))))))]
|
||||
|
||||
(ptk/reify ::logged-in
|
||||
ptk/WatchEvent
|
||||
|
||||
@ -36,6 +36,18 @@
|
||||
[]
|
||||
(::current-team-id storage/global))
|
||||
|
||||
(defn resolve-login-team-id
|
||||
"Resolve the team to navigate to after login. Falls back to the
|
||||
default team when the candidate requires SSO and the user has no
|
||||
valid SSO session for it."
|
||||
[{:keys [team-id default-team-id]}]
|
||||
(if (or (not (contains? cf/flags :nitrate))
|
||||
(= team-id default-team-id))
|
||||
(rx/of team-id)
|
||||
(->> (rp/cmd! :check-nitrate-sso {:team-id team-id :url (rt/get-current-href)})
|
||||
(rx/map (fn [{:keys [authorized]}]
|
||||
(if authorized team-id default-team-id))))))
|
||||
|
||||
(defn teams-fetched
|
||||
[teams]
|
||||
(ptk/reify ::teams-fetched
|
||||
|
||||
@ -156,12 +156,19 @@
|
||||
(st/emit! (rt/nav :auth-login)))
|
||||
|
||||
empty-path?
|
||||
(let [team-id (dtm/get-last-team-id)]
|
||||
(if (contains? teams team-id)
|
||||
(st/emit! (rt/nav :dashboard-recent
|
||||
(assoc query-params :team-id team-id)))
|
||||
(st/emit! (rt/nav :dashboard-recent
|
||||
(assoc query-params :team-id (:default-team-id profile))))))
|
||||
(let [default-team-id (:default-team-id profile)
|
||||
last-team-id (dtm/get-last-team-id)
|
||||
team-id (if (contains? teams last-team-id)
|
||||
last-team-id
|
||||
default-team-id)]
|
||||
(->> (dtm/resolve-login-team-id {:team-id team-id
|
||||
:default-team-id default-team-id})
|
||||
(rx/subs!
|
||||
(fn [team-id]
|
||||
(st/emit! (rt/nav :dashboard-recent
|
||||
(assoc query-params :team-id team-id))))
|
||||
(fn [cause]
|
||||
(errors/on-error cause)))))
|
||||
|
||||
:else
|
||||
(st/emit! (rt/assign-exception {:type :not-found}))))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user