1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-11-28 12:35:40 +01:00

[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