Skip to content

Commit 999229d

Browse files
authored
fix: prevent claim own share (#259)
1 parent 3f315a1 commit 999229d

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

API/Controller/Shares/UserShares/Invites.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,13 @@ public async Task<IActionResult> RedeemInvite([FromRoute] Guid inviteId, [FromSe
122122
.FirstOrDefaultAsync(x => x.Id == inviteId && (x.RecipientUserId == null || x.RecipientUserId == CurrentUser.Id));
123123

124124
if (shareRequest is null) return Problem(ShareError.ShareRequestNotFound);
125-
125+
126+
var isShareOwner = shareRequest.OwnerId == CurrentUser.Id;
127+
if (isShareOwner)
128+
{
129+
return Problem(ShareError.ShareRequestCreateCannotShareWithSelf);
130+
}
131+
126132
var alreadySharedShockers = await _db.UserShares.Where(x => x.Shocker.Device.Owner.Id == shareRequest.OwnerId && x.SharedWithUserId == CurrentUser.Id).ToListAsync();
127133

128134
foreach (var shareInvitationShocker in shareRequest.ShockerMappings)

0 commit comments

Comments
 (0)