1
0
mirror of https://github.com/bitwarden/server synced 2026-02-12 14:33:49 +00:00

[PM-31497] use remove auth logic for remove password (#6929)

* [PM-31497] use remove auth logic for remove password

* [PM-31497] removing non-existent field
This commit is contained in:
Alex Dragovich
2026-02-09 17:38:29 -08:00
committed by GitHub
parent 6d43cc43e3
commit e5cf9dff2e

View File

@@ -387,19 +387,7 @@ public class SendsController : Controller
[HttpPut("{id}/remove-password")]
public async Task<SendResponseModel> PutRemovePassword(string id)
{
var userId = _userService.GetProperUserId(User) ?? throw new InvalidOperationException("User ID not found");
var send = await _sendRepository.GetByIdAsync(new Guid(id));
if (send == null || send.UserId != userId)
{
throw new NotFoundException();
}
// This endpoint exists because PUT preserves existing Password/Emails when not provided.
// This allows clients to update other fields without re-submitting sensitive auth data.
send.Password = null;
send.AuthType = AuthType.None;
await _nonAnonymousSendCommand.SaveSendAsync(send);
return new SendResponseModel(send);
return await this.PutRemoveAuth(id);
}
// Removes ALL authentication (email or password) if any is present