~netlandish/links

ffcbea12a26797cb9ac53d2fd901d47c55aea460 — Peter Sanchez a month ago b7f6dd6
Fixing issue where user continued to view links for an org they no
longer had access to. The org slug was set in the users session and not
removed, even after the org removed the user. Now we check on page load.
1 files changed, 21 insertions(+), 1 deletions(-)

M helpers.go
M helpers.go => helpers.go +21 -1
@@ 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 ...