@@ 251,7 251,27 @@ func PullOrgSlug(c echo.Context) string {
return slug
}
- return GetOrgSelection(c)
+ orgSlug := GetOrgSelection(c)
+ gctx := c.(*server.Context)
+ user := gctx.User.(*models.User)
+ orgs, err := user.GetOrgs(c.Request().Context(), models.OrgUserPermissionRead)
+ if err != nil {
+ return orgSlug
+ }
+ if len(orgs) == 0 {
+ return ""
+ }
+
+ for _, org := range orgs {
+ if org.Slug == orgSlug {
+ return orgSlug
+ }
+ }
+
+ // User no longer has access to the organization that was stored in their session.
+ // Set it to one they do have access to.
+ SetOrgSelection(c, orgs[0])
+ return orgs[0].Slug
}
// GetTZ ...