Skip to content

Commit

Permalink
document access control rules in validateCompanyAccess
Browse files Browse the repository at this point in the history
  • Loading branch information
AmirAgassi committed Dec 27, 2024
1 parent c057b3b commit 51fd799
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions backend/internal/v1/v1_teams/members.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,25 @@ func (h *Handler) handleDeleteTeamMember(c echo.Context) error {
return v1_common.Success(c, http.StatusOK, "Team member successfully deleted")
}

/*
* Validates if the current user has access to the specified company
* Access rules:
* - Company owners have full access regardless of requireOwner value
* - When requireOwner is true, only company owners are allowed
* - When requireOwner is false:
* - Company owners are allowed
* - Investors are allowed read-only access
* - Other users are denied access
*
* Parameters:
* - c: Echo context containing the authenticated user
* - companyID: ID of the company to check access for
* - requireOwner: If true, only allows company owners. If false, allows owners and investors.
*
* Returns:
* - nil if access is granted
* - error if access is denied or validation fails
*/
func (h *Handler) validateCompanyAccess(c echo.Context, companyID string, requireOwner bool) error {
user := c.Get("user").(*db.GetUserByIDRow)
if user == nil {
Expand Down

0 comments on commit 51fd799

Please sign in to comment.