mirror of
https://github.com/bitwarden/server.git
synced 2025-07-01 08:02:49 -05:00
Enforce 2fa policy (#654)
This commit is contained in:
@ -120,7 +120,7 @@ namespace Bit.Api.Controllers
|
||||
throw new UnauthorizedAccessException();
|
||||
}
|
||||
|
||||
var result = await _organizationService.AcceptUserAsync(new Guid(id), user, model.Token);
|
||||
var result = await _organizationService.AcceptUserAsync(new Guid(id), user, model.Token, _userService);
|
||||
}
|
||||
|
||||
[HttpPost("{id}/confirm")]
|
||||
|
@ -18,15 +18,21 @@ namespace Bit.Api.Controllers
|
||||
{
|
||||
private readonly IPolicyRepository _policyRepository;
|
||||
private readonly IPolicyService _policyService;
|
||||
private readonly IOrganizationService _organizationService;
|
||||
private readonly IUserService _userService;
|
||||
private readonly CurrentContext _currentContext;
|
||||
|
||||
public PoliciesController(
|
||||
IPolicyRepository policyRepository,
|
||||
IPolicyService policyService,
|
||||
IOrganizationService organizationService,
|
||||
IUserService userService,
|
||||
CurrentContext currentContext)
|
||||
{
|
||||
_policyRepository = policyRepository;
|
||||
_policyService = policyService;
|
||||
_organizationService = organizationService;
|
||||
_userService = userService;
|
||||
_currentContext = currentContext;
|
||||
}
|
||||
|
||||
@ -79,7 +85,8 @@ namespace Bit.Api.Controllers
|
||||
policy = model.ToPolicy(policy);
|
||||
}
|
||||
|
||||
await _policyService.SaveAsync(policy);
|
||||
var userId = _userService.GetProperUserId(User);
|
||||
await _policyService.SaveAsync(policy, _userService, _organizationService, userId);
|
||||
return new PolicyResponseModel(policy);
|
||||
}
|
||||
}
|
||||
|
@ -318,7 +318,7 @@ namespace Bit.Api.Controllers
|
||||
public async Task<TwoFactorProviderResponseModel> PutDisable([FromBody]TwoFactorProviderRequestModel model)
|
||||
{
|
||||
var user = await CheckAsync(model.MasterPasswordHash, false);
|
||||
await _userService.DisableTwoFactorProviderAsync(user, model.Type.Value);
|
||||
await _userService.DisableTwoFactorProviderAsync(user, model.Type.Value, _organizationService);
|
||||
var response = new TwoFactorProviderResponseModel(model.Type.Value, user);
|
||||
return response;
|
||||
}
|
||||
|
@ -18,15 +18,21 @@ namespace Bit.Api.Public.Controllers
|
||||
{
|
||||
private readonly IPolicyRepository _policyRepository;
|
||||
private readonly IPolicyService _policyService;
|
||||
private readonly IUserService _userService;
|
||||
private readonly IOrganizationService _organizationService;
|
||||
private readonly CurrentContext _currentContext;
|
||||
|
||||
public PoliciesController(
|
||||
IPolicyRepository policyRepository,
|
||||
IPolicyService policyService,
|
||||
IUserService userService,
|
||||
IOrganizationService organizationService,
|
||||
CurrentContext currentContext)
|
||||
{
|
||||
_policyRepository = policyRepository;
|
||||
_policyService = policyService;
|
||||
_userService = userService;
|
||||
_organizationService = organizationService;
|
||||
_currentContext = currentContext;
|
||||
}
|
||||
|
||||
@ -93,7 +99,7 @@ namespace Bit.Api.Public.Controllers
|
||||
{
|
||||
policy = model.ToPolicy(policy);
|
||||
}
|
||||
await _policyService.SaveAsync(policy);
|
||||
await _policyService.SaveAsync(policy, _userService, _organizationService, null);
|
||||
var response = new PolicyResponseModel(policy);
|
||||
return new JsonResult(response);
|
||||
}
|
||||
|
Reference in New Issue
Block a user