diff --git a/angular/src/components/set-password.component.ts b/angular/src/components/set-password.component.ts index 2b8a11de12e..779559e6fb8 100644 --- a/angular/src/components/set-password.component.ts +++ b/angular/src/components/set-password.component.ts @@ -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(); diff --git a/common/src/abstractions/api.service.ts b/common/src/abstractions/api.service.ts index 893aaf3ddd7..0dec0c8cefa 100644 --- a/common/src/abstractions/api.service.ts +++ b/common/src/abstractions/api.service.ts @@ -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'; @@ -370,6 +371,7 @@ export abstract class ApiService { getOrganizationSubscription: (id: string) => Promise; getOrganizationLicense: (id: string, installationId: string) => Promise; getOrganizationTaxInfo: (id: string) => Promise; + getOrganizationAutoEnrollStatus: (identifier: string) => Promise; postOrganization: (request: OrganizationCreateRequest) => Promise; putOrganization: (id: string, request: OrganizationUpdateRequest) => Promise; putOrganizationTaxInfo: (id: string, request: OrganizationTaxInfoUpdateRequest) => Promise; diff --git a/common/src/models/response/organizationAutoEnrollStatusResponse.ts b/common/src/models/response/organizationAutoEnrollStatusResponse.ts new file mode 100644 index 00000000000..1f9f77b52e0 --- /dev/null +++ b/common/src/models/response/organizationAutoEnrollStatusResponse.ts @@ -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'); + } +} diff --git a/common/src/services/api.service.ts b/common/src/services/api.service.ts index 285f3b8b744..06af9904ff2 100644 --- a/common/src/services/api.service.ts +++ b/common/src/services/api.service.ts @@ -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'; @@ -812,6 +813,11 @@ export class ApiService implements ApiServiceAbstraction { return new OrganizationUserResetPasswordDetailsReponse(r); } + async getOrganizationAutoEnrollStatus(identifier: string): Promise { + const r = await this.send('GET', '/organizations/' + identifier + '/auto-enroll-status', null, true, true); + return new OrganizationAutoEnrollStatusResponse(r); + } + postOrganizationUserInvite(organizationId: string, request: OrganizationUserInviteRequest): Promise { return this.send('POST', '/organizations/' + organizationId + '/users/invite', request, true, false); }