1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-03 09:02:48 -05:00

user null checks for unauthorized

This commit is contained in:
Kyle Spearrin
2017-06-02 13:17:46 -04:00
parent 57b4a32194
commit ef3d5ee10c
6 changed files with 99 additions and 0 deletions

View File

@ -95,6 +95,11 @@ namespace Bit.Api.Controllers
public async Task<OrganizationResponseModel> Post([FromBody]OrganizationCreateRequestModel model)
{
var user = await _userService.GetUserByPrincipalAsync(User);
if(user == null)
{
throw new UnauthorizedAccessException();
}
var organizationSignup = model.ToOrganizationSignup(user);
var result = await _organizationService.SignUpAsync(organizationSignup);
return new OrganizationResponseModel(result.Item1);
@ -218,6 +223,11 @@ namespace Bit.Api.Controllers
}
var user = await _userService.GetUserByPrincipalAsync(User);
if(user == null)
{
throw new UnauthorizedAccessException();
}
if(!await _userManager.CheckPasswordAsync(user, model.MasterPasswordHash))
{
ModelState.AddModelError("MasterPasswordHash", "Invalid password.");