Skip to content
This repository has been archived by the owner on Jun 17, 2022. It is now read-only.

Commit

Permalink
[SSO Auto Enroll] Auto Enroll status retrieval (#486)
Browse files Browse the repository at this point in the history
* [SSO Auto Enroll] Auto Enroll status retrieval

* Fixed import order

* Updated object property
  • Loading branch information
vincentsalucci committed Sep 15, 2021
1 parent ee1ea92 commit da13221
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
12 changes: 7 additions & 5 deletions angular/src/components/set-password.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,13 @@ export class SetPasswordComponent extends BaseChangePasswordComponent {

// Automatic Enrollment Detection
if (this.identifier != null) {
const org = await this.userService.getOrganizationByIdentifier(this.identifier);
this.orgId = org?.id;
const policyList = await this.policyService.getAll(PolicyType.ResetPassword);
const policyResult = this.policyService.getResetPasswordPolicyOptions(policyList, this.orgId);
this.resetPasswordAutoEnroll = policyResult[1] && policyResult[0].autoEnrollEnabled;
try {
const response = await this.apiService.getOrganizationAutoEnrollStatus(this.identifier);
this.orgId = response.id;
this.resetPasswordAutoEnroll = response.resetPasswordEnabled;
} catch {
this.platformUtilsService.showToast('error', null, this.i18nService.t('errorOccurred'));
}
}

super.ngOnInit();
Expand Down
2 changes: 2 additions & 0 deletions common/src/abstractions/api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ import { IdentityCaptchaResponse } from '../models/response/identityCaptchaRespo
import { IdentityTokenResponse } from '../models/response/identityTokenResponse';
import { IdentityTwoFactorResponse } from '../models/response/identityTwoFactorResponse';
import { ListResponse } from '../models/response/listResponse';
import { OrganizationAutoEnrollStatusResponse } from '../models/response/organizationAutoEnrollStatusResponse';
import { OrganizationKeysResponse } from '../models/response/organizationKeysResponse';
import { OrganizationResponse } from '../models/response/organizationResponse';
import { OrganizationSubscriptionResponse } from '../models/response/organizationSubscriptionResponse';
Expand Down Expand Up @@ -370,6 +371,7 @@ export abstract class ApiService {
getOrganizationSubscription: (id: string) => Promise<OrganizationSubscriptionResponse>;
getOrganizationLicense: (id: string, installationId: string) => Promise<any>;
getOrganizationTaxInfo: (id: string) => Promise<TaxInfoResponse>;
getOrganizationAutoEnrollStatus: (identifier: string) => Promise<OrganizationAutoEnrollStatusResponse>;
postOrganization: (request: OrganizationCreateRequest) => Promise<OrganizationResponse>;
putOrganization: (id: string, request: OrganizationUpdateRequest) => Promise<OrganizationResponse>;
putOrganizationTaxInfo: (id: string, request: OrganizationTaxInfoUpdateRequest) => Promise<any>;
Expand Down
12 changes: 12 additions & 0 deletions common/src/models/response/organizationAutoEnrollStatusResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { BaseResponse } from './baseResponse';

export class OrganizationAutoEnrollStatusResponse extends BaseResponse {
id: string;
resetPasswordEnabled: boolean;

constructor(response: any) {
super(response);
this.id = this.getResponseProperty('Id');
this.resetPasswordEnabled = this.getResponseProperty('ResetPasswordEnabled');
}
}
6 changes: 6 additions & 0 deletions common/src/services/api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ import {
import { IdentityTokenResponse } from '../models/response/identityTokenResponse';
import { IdentityTwoFactorResponse } from '../models/response/identityTwoFactorResponse';
import { ListResponse } from '../models/response/listResponse';
import { OrganizationAutoEnrollStatusResponse } from '../models/response/organizationAutoEnrollStatusResponse';
import { OrganizationKeysResponse } from '../models/response/organizationKeysResponse';
import { OrganizationResponse } from '../models/response/organizationResponse';
import { OrganizationSubscriptionResponse } from '../models/response/organizationSubscriptionResponse';
Expand Down Expand Up @@ -812,6 +813,11 @@ export class ApiService implements ApiServiceAbstraction {
return new OrganizationUserResetPasswordDetailsReponse(r);
}

async getOrganizationAutoEnrollStatus(identifier: string): Promise<OrganizationAutoEnrollStatusResponse> {
const r = await this.send('GET', '/organizations/' + identifier + '/auto-enroll-status', null, true, true);
return new OrganizationAutoEnrollStatusResponse(r);
}

postOrganizationUserInvite(organizationId: string, request: OrganizationUserInviteRequest): Promise<any> {
return this.send('POST', '/organizations/' + organizationId + '/users/invite', request, true, false);
}
Expand Down

0 comments on commit da13221

Please sign in to comment.