Avoid going to last team on login if it is protected by sso (#10442)

This commit is contained in:
Pablo Alba 2026-06-29 09:44:16 +02:00 committed by GitHub
parent 5212e2202b
commit a9f3949abc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 35 additions and 12 deletions

View File

@ -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

View File

@ -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

View File

@ -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}))))