Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 8 additions & 13 deletions enterprise/server/backends/authdb/authdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -827,21 +827,16 @@ func (d *AuthDB) CreateUserAPIKey(ctx context.Context, groupID, userID, label st
}

func (d *AuthDB) isGroupMember(ctx context.Context, groupID, userID string) (bool, error) {
q := d.env.GetDBHandle().NewQuery(ctx, "authdb_check_group_membership").Raw(`
SELECT *
FROM "UserGroups"
WHERE group_group_id = ?
AND user_user_id = ?
AND membership_status = ?
`, groupID, userID, grpb.GroupMembershipStatus_MEMBER)
ug := &tables.UserGroup{}
if err := q.Take(ug); err != nil {
if db.IsRecordNotFound(err) {
return false, nil
}
u, err := d.env.GetUserDB().GetUserByIDWithoutAuthCheck(ctx, userID)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish we could not use this method anymore

if err != nil {
return false, err
}
return true, nil
for _, g := range u.Groups {
if g.GroupID == groupID {
return true, nil
}
}
return false, nil
}

func (d *AuthDB) getAPIKey(ctx context.Context, h interfaces.DB, apiKeyID string) (*tables.APIKey, error) {
Expand Down
Loading