Skip to content

Commit

Permalink
fix: team_user delete problem
Browse files Browse the repository at this point in the history
  • Loading branch information
ElaBosak233 committed Apr 1, 2024
1 parent 1ebc7eb commit b9bd6a9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion internal/casbin/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ func initDefaultPolicy() {
{"user", "/api/teams/", "POST"},
{"user", "/api/teams/{id}", "PUT"},
{"user", "/api/teams/{id}", "GET"},
{"user", "/api/teams/{id}", "DELETE"},
{"user", "/api/teams/{id}/invite", "PUT"},
{"user", "/api/teams/{id}/invite", "GET"},
{"user", "/api/teams/{id}/users", "DELETE"},
{"user", "/api/teams/{id}/users/{user_id}", "DELETE"},
{"user", "/api/teams/{id}/join", "POST"},
{"user", "/api/teams/{id}/leave", "DELETE"},
{"user", "/api/challenges/", "GET"},
Expand Down
5 changes: 4 additions & 1 deletion internal/repository/user_team.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ func (t *UserTeamRepository) Insert(userTeam model.UserTeam) error {
}

func (t *UserTeamRepository) Delete(userTeam model.UserTeam) error {
result := t.db.Table("user_teams").Delete(&userTeam)
result := t.db.Table("user_teams").
Where("user_id = ?", userTeam.UserID).
Where("team_id = ?", userTeam.TeamID).
Delete(&userTeam)
return result.Error
}

Expand Down

0 comments on commit b9bd6a9

Please sign in to comment.