[SSO Auto Enroll] Auto Enroll status retrieval (#1540)

* [SSO Auto Enroll] Auto Enroll status retrieval

* Updated object property to match server
This commit is contained in:
Vincent Salucci 2021-09-15 12:27:27 -05:00 committed by GitHub
parent 14b51b1a7f
commit 024d9380c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 6 deletions

View file

@ -97,12 +97,21 @@ namespace Bit.App.Pages
public async Task InitAsync()
{
await CheckPasswordPolicy();
var org = await _userService.GetOrganizationByIdentifierAsync(OrgIdentifier);
OrgId = org?.Id;
var policyList = await _policyService.GetAll(PolicyType.ResetPassword);
var policyResult = _policyService.GetResetPasswordPolicyOptions(policyList, OrgId);
ResetPasswordAutoEnroll = policyResult.Item2 && policyResult.Item1.AutoEnrollEnabled;
try
{
var response = await _apiService.GetOrganizationAutoEnrollStatusAsync(OrgIdentifier);
OrgId = response.Id;
ResetPasswordAutoEnroll = response.ResetPasswordEnrolled;
}
catch (ApiException e)
{
if (e?.Error != null)
{
await _platformUtilsService.ShowDialogAsync(e.Error.GetSingleMessage(),
AppResources.AnErrorHasOccurred);
}
}
}
public async Task SubmitAsync()

View file

@ -59,6 +59,7 @@ namespace Bit.Core.Abstractions
Task PutDeviceTokenAsync(string identifier, DeviceTokenRequest request);
Task PostEventsCollectAsync(IEnumerable<EventRequest> request);
Task<OrganizationKeysResponse> GetOrganizationKeysAsync(string id);
Task<OrganizationAutoEnrollStatusResponse> GetOrganizationAutoEnrollStatusAsync(string identifier);
Task PutOrganizationUserResetPasswordEnrollmentAsync(string orgId, string userId,
OrganizationUserResetPasswordEnrollmentRequest request);

View file

@ -0,0 +1,8 @@
namespace Bit.Core.Models.Response
{
public class OrganizationAutoEnrollStatusResponse
{
public string Id { get; set; }
public bool ResetPasswordEnrolled { get; set; }
}
}

View file

@ -410,6 +410,12 @@ namespace Bit.Core.Services
{
return SendAsync<object, OrganizationKeysResponse>(HttpMethod.Get, $"/organizations/{id}/keys", null, true, true);
}
public Task<OrganizationAutoEnrollStatusResponse> GetOrganizationAutoEnrollStatusAsync(string identifier)
{
return SendAsync<object, OrganizationAutoEnrollStatusResponse>(HttpMethod.Get,
$"/organizations/{identifier}/auto-enroll-status", null, true, true);
}
#endregion