1
0
mirror of https://github.com/bitwarden/server synced 2025-12-22 11:13:27 +00:00

Add logic to handle providers password reseting users (#1632)

This commit is contained in:
Oscar Hinton
2021-10-14 17:44:20 +02:00
committed by GitHub
parent e3a1482e3e
commit 4fee17fdde

View File

@@ -284,14 +284,16 @@ namespace Bit.Api.Controllers
throw new NotFoundException(); throw new NotFoundException();
} }
// Get the calling user's Type for this organization and pass it along // Get the users role, since provider users aren't a member of the organization we use the owner check
var orgType = _currentContext.Organizations?.FirstOrDefault(o => o.Id == orgGuidId)?.Type; var orgUserType = await _currentContext.OrganizationOwner(orgGuidId)
if (orgType == null) ? OrganizationUserType.Owner
: _currentContext.Organizations?.FirstOrDefault(o => o.Id == orgGuidId)?.Type;
if (orgUserType == null)
{ {
throw new NotFoundException(); throw new NotFoundException();
} }
var result = await _userService.AdminResetPasswordAsync(orgType.Value, orgGuidId, new Guid(id), model.NewMasterPasswordHash, model.Key); var result = await _userService.AdminResetPasswordAsync(orgUserType.Value, orgGuidId, new Guid(id), model.NewMasterPasswordHash, model.Key);
if (result.Succeeded) if (result.Succeeded)
{ {
return; return;