Use MP policies when registering a new user through SSO (#587)
* use MP policies when registering a new user through SSO * prettier and linting
This commit is contained in:
parent
9e26336549
commit
3d7b427b0e
|
@ -40,7 +40,7 @@ export class ChangePasswordComponent implements OnInit {
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
this.email = await this.stateService.getEmail();
|
this.email = await this.stateService.getEmail();
|
||||||
this.enforcedPolicyOptions = await this.policyService.getMasterPasswordPolicyOptions();
|
this.enforcedPolicyOptions ??= await this.policyService.getMasterPasswordPolicyOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
async submit() {
|
async submit() {
|
||||||
|
|
|
@ -79,6 +79,8 @@ export class SetPasswordComponent extends BaseChangePasswordComponent {
|
||||||
const response = await this.apiService.getOrganizationAutoEnrollStatus(this.identifier);
|
const response = await this.apiService.getOrganizationAutoEnrollStatus(this.identifier);
|
||||||
this.orgId = response.id;
|
this.orgId = response.id;
|
||||||
this.resetPasswordAutoEnroll = response.resetPasswordEnabled;
|
this.resetPasswordAutoEnroll = response.resetPasswordEnabled;
|
||||||
|
this.enforcedPolicyOptions =
|
||||||
|
await this.policyService.getMasterPasswordPoliciesForInvitedUsers(this.orgId);
|
||||||
} catch {
|
} catch {
|
||||||
this.platformUtilsService.showToast("error", null, this.i18nService.t("errorOccurred"));
|
this.platformUtilsService.showToast("error", null, this.i18nService.t("errorOccurred"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -355,6 +355,10 @@ export abstract class ApiService {
|
||||||
email: string,
|
email: string,
|
||||||
organizationUserId: string
|
organizationUserId: string
|
||||||
) => Promise<ListResponse<PolicyResponse>>;
|
) => Promise<ListResponse<PolicyResponse>>;
|
||||||
|
getPoliciesByInvitedUser: (
|
||||||
|
organizationId: string,
|
||||||
|
userId: string
|
||||||
|
) => Promise<ListResponse<PolicyResponse>>;
|
||||||
putPolicy: (
|
putPolicy: (
|
||||||
organizationId: string,
|
organizationId: string,
|
||||||
type: PolicyType,
|
type: PolicyType,
|
||||||
|
|
|
@ -15,6 +15,7 @@ export abstract class PolicyService {
|
||||||
getPolicyForOrganization: (policyType: PolicyType, organizationId: string) => Promise<Policy>;
|
getPolicyForOrganization: (policyType: PolicyType, organizationId: string) => Promise<Policy>;
|
||||||
replace: (policies: { [id: string]: PolicyData }) => Promise<any>;
|
replace: (policies: { [id: string]: PolicyData }) => Promise<any>;
|
||||||
clear: (userId?: string) => Promise<any>;
|
clear: (userId?: string) => Promise<any>;
|
||||||
|
getMasterPasswordPoliciesForInvitedUsers: (orgId: string) => Promise<MasterPasswordPolicyOptions>;
|
||||||
getMasterPasswordPolicyOptions: (policies?: Policy[]) => Promise<MasterPasswordPolicyOptions>;
|
getMasterPasswordPolicyOptions: (policies?: Policy[]) => Promise<MasterPasswordPolicyOptions>;
|
||||||
evaluateMasterPassword: (
|
evaluateMasterPassword: (
|
||||||
passwordStrength: number,
|
passwordStrength: number,
|
||||||
|
|
|
@ -1047,6 +1047,20 @@ export class ApiService implements ApiServiceAbstraction {
|
||||||
return new ListResponse(r, PolicyResponse);
|
return new ListResponse(r, PolicyResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getPoliciesByInvitedUser(
|
||||||
|
organizationId: string,
|
||||||
|
userId: string
|
||||||
|
): Promise<ListResponse<PolicyResponse>> {
|
||||||
|
const r = await this.send(
|
||||||
|
"GET",
|
||||||
|
"/organizations/" + organizationId + "/policies/invited-user?" + "userId=" + userId,
|
||||||
|
null,
|
||||||
|
false,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
return new ListResponse(r, PolicyResponse);
|
||||||
|
}
|
||||||
|
|
||||||
async putPolicy(
|
async putPolicy(
|
||||||
organizationId: string,
|
organizationId: string,
|
||||||
type: PolicyType,
|
type: PolicyType,
|
||||||
|
|
|
@ -78,6 +78,15 @@ export class PolicyService implements PolicyServiceAbstraction {
|
||||||
await this.stateService.setEncryptedPolicies(null, { userId: userId });
|
await this.stateService.setEncryptedPolicies(null, { userId: userId });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getMasterPasswordPoliciesForInvitedUsers(
|
||||||
|
orgId: string
|
||||||
|
): Promise<MasterPasswordPolicyOptions> {
|
||||||
|
const userId = await this.stateService.getUserId();
|
||||||
|
const response = await this.apiService.getPoliciesByInvitedUser(orgId, userId);
|
||||||
|
const policies = await this.mapPoliciesFromToken(response);
|
||||||
|
return this.getMasterPasswordPolicyOptions(policies);
|
||||||
|
}
|
||||||
|
|
||||||
async getMasterPasswordPolicyOptions(policies?: Policy[]): Promise<MasterPasswordPolicyOptions> {
|
async getMasterPasswordPolicyOptions(policies?: Policy[]): Promise<MasterPasswordPolicyOptions> {
|
||||||
let enforcedOptions: MasterPasswordPolicyOptions = null;
|
let enforcedOptions: MasterPasswordPolicyOptions = null;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue