mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-02 20:32:19 +00:00
feat: add notification policy and password change message (#5065)
Implementation of new notification policy with functionality to send email when a password is changed
This commit is contained in:
@@ -3,31 +3,39 @@ import { MatLegacyDialog as MatDialog } from '@angular/material/legacy-dialog';
|
||||
import { MatLegacySelectChange as MatSelectChange } from '@angular/material/legacy-select';
|
||||
import { BehaviorSubject, from, Observable, of, Subscription } from 'rxjs';
|
||||
import {
|
||||
GetCustomPasswordResetMessageTextRequest as AdminGetCustomPasswordResetMessageTextRequest,
|
||||
GetDefaultInitMessageTextRequest as AdminGetDefaultInitMessageTextRequest,
|
||||
GetDefaultVerifyEmailMessageTextRequest as AdminGetDefaultVerifyEmailMessageTextRequest,
|
||||
GetDefaultVerifyPhoneMessageTextRequest as AdminGetDefaultVerifyPhoneMessageTextRequest,
|
||||
SetDefaultDomainClaimedMessageTextRequest,
|
||||
SetDefaultInitMessageTextRequest,
|
||||
SetDefaultPasswordChangeMessageTextRequest,
|
||||
SetDefaultPasswordlessRegistrationMessageTextRequest,
|
||||
SetDefaultPasswordResetMessageTextRequest,
|
||||
SetDefaultVerifyEmailMessageTextRequest,
|
||||
SetDefaultVerifyPhoneMessageTextRequest,
|
||||
GetDefaultPasswordChangeMessageTextRequest as AdminGetDefaultPasswordChangeMessageTextRequest,
|
||||
GetDefaultInitMessageTextRequest as AdminGetDefaultInitMessageTextRequest,
|
||||
GetDefaultVerifyEmailMessageTextRequest as AdminGetDefaultVerifyEmailMessageTextRequest,
|
||||
GetDefaultVerifyPhoneMessageTextRequest as AdminGetDefaultVerifyPhoneMessageTextRequest,
|
||||
GetDefaultPasswordResetMessageTextRequest as AdminGetDefaultPasswordResetMessageTextRequest,
|
||||
GetDefaultDomainClaimedMessageTextRequest as AdminGetDefaultDomainClaimedMessageTextRequest,
|
||||
GetDefaultPasswordlessRegistrationMessageTextRequest as AdminGetDefaultPasswordlessRegistrationMessageTextRequest,
|
||||
} from 'src/app/proto/generated/zitadel/admin_pb';
|
||||
import {
|
||||
GetCustomDomainClaimedMessageTextRequest,
|
||||
GetCustomInitMessageTextRequest,
|
||||
GetCustomPasswordChangeMessageTextRequest,
|
||||
GetCustomPasswordlessRegistrationMessageTextRequest,
|
||||
GetCustomPasswordResetMessageTextRequest,
|
||||
GetCustomVerifyEmailMessageTextRequest,
|
||||
GetCustomVerifyPhoneMessageTextRequest,
|
||||
GetDefaultDomainClaimedMessageTextRequest,
|
||||
GetDefaultInitMessageTextRequest,
|
||||
GetDefaultPasswordChangeMessageTextRequest,
|
||||
GetDefaultPasswordlessRegistrationMessageTextRequest,
|
||||
GetDefaultPasswordResetMessageTextRequest,
|
||||
GetDefaultVerifyEmailMessageTextRequest,
|
||||
GetDefaultVerifyPhoneMessageTextRequest,
|
||||
SetCustomDomainClaimedMessageTextRequest,
|
||||
SetCustomInitMessageTextRequest,
|
||||
SetCustomPasswordChangeMessageTextRequest,
|
||||
SetCustomPasswordlessRegistrationMessageTextRequest,
|
||||
SetCustomPasswordResetMessageTextRequest,
|
||||
SetCustomVerifyEmailMessageTextRequest,
|
||||
@@ -50,12 +58,30 @@ enum MESSAGETYPES {
|
||||
PASSWORDRESET = 'PR',
|
||||
DOMAINCLAIMED = 'DC',
|
||||
PASSWORDLESS = 'PL',
|
||||
PASSWORDCHANGE = 'PC',
|
||||
}
|
||||
|
||||
const REQUESTMAP = {
|
||||
[PolicyComponentServiceType.MGMT]: {
|
||||
[MESSAGETYPES.PASSWORDCHANGE]: {
|
||||
get: new GetCustomPasswordChangeMessageTextRequest(),
|
||||
set: new SetCustomPasswordChangeMessageTextRequest(),
|
||||
getDefault: new GetDefaultPasswordChangeMessageTextRequest(),
|
||||
setFcn: (map: Partial<MessageCustomText.AsObject>): SetCustomPasswordChangeMessageTextRequest => {
|
||||
const req = new SetCustomPasswordChangeMessageTextRequest();
|
||||
req.setButtonText(map.buttonText ?? '');
|
||||
req.setFooterText(map.footerText ?? '');
|
||||
req.setGreeting(map.greeting ?? '');
|
||||
req.setPreHeader(map.preHeader ?? '');
|
||||
req.setSubject(map.subject ?? '');
|
||||
req.setText(map.text ?? '');
|
||||
req.setTitle(map.title ?? '');
|
||||
|
||||
return req;
|
||||
},
|
||||
},
|
||||
[MESSAGETYPES.INIT]: {
|
||||
get: new GetDefaultInitMessageTextRequest(),
|
||||
get: new GetCustomInitMessageTextRequest(),
|
||||
set: new SetCustomInitMessageTextRequest(),
|
||||
getDefault: new GetDefaultInitMessageTextRequest(),
|
||||
setFcn: (map: Partial<MessageCustomText.AsObject>): SetCustomInitMessageTextRequest => {
|
||||
@@ -164,6 +190,22 @@ const REQUESTMAP = {
|
||||
},
|
||||
},
|
||||
[PolicyComponentServiceType.ADMIN]: {
|
||||
[MESSAGETYPES.PASSWORDCHANGE]: {
|
||||
get: new AdminGetDefaultPasswordChangeMessageTextRequest(),
|
||||
set: new SetDefaultPasswordChangeMessageTextRequest(),
|
||||
setFcn: (map: Partial<MessageCustomText.AsObject>): SetDefaultPasswordChangeMessageTextRequest => {
|
||||
const req = new SetDefaultPasswordChangeMessageTextRequest();
|
||||
req.setButtonText(map.buttonText ?? '');
|
||||
req.setFooterText(map.footerText ?? '');
|
||||
req.setGreeting(map.greeting ?? '');
|
||||
req.setPreHeader(map.preHeader ?? '');
|
||||
req.setSubject(map.subject ?? '');
|
||||
req.setText(map.text ?? '');
|
||||
req.setTitle(map.title ?? '');
|
||||
|
||||
return req;
|
||||
},
|
||||
},
|
||||
[MESSAGETYPES.INIT]: {
|
||||
get: new AdminGetDefaultInitMessageTextRequest(),
|
||||
set: new SetDefaultInitMessageTextRequest(),
|
||||
@@ -213,7 +255,7 @@ const REQUESTMAP = {
|
||||
},
|
||||
},
|
||||
[MESSAGETYPES.PASSWORDRESET]: {
|
||||
get: new AdminGetCustomPasswordResetMessageTextRequest(),
|
||||
get: new AdminGetDefaultPasswordResetMessageTextRequest(),
|
||||
set: new SetDefaultPasswordResetMessageTextRequest(),
|
||||
setFcn: (
|
||||
map: Partial<SetDefaultPasswordResetMessageTextRequest.AsObject>,
|
||||
@@ -231,7 +273,7 @@ const REQUESTMAP = {
|
||||
},
|
||||
},
|
||||
[MESSAGETYPES.DOMAINCLAIMED]: {
|
||||
get: new GetDefaultDomainClaimedMessageTextRequest(),
|
||||
get: new AdminGetDefaultDomainClaimedMessageTextRequest(),
|
||||
set: new SetDefaultDomainClaimedMessageTextRequest(),
|
||||
setFcn: (
|
||||
map: Partial<SetDefaultDomainClaimedMessageTextRequest.AsObject>,
|
||||
@@ -249,7 +291,7 @@ const REQUESTMAP = {
|
||||
},
|
||||
},
|
||||
[MESSAGETYPES.PASSWORDLESS]: {
|
||||
get: new GetDefaultPasswordlessRegistrationMessageTextRequest(),
|
||||
get: new AdminGetDefaultPasswordlessRegistrationMessageTextRequest(),
|
||||
set: new SetDefaultPasswordlessRegistrationMessageTextRequest(),
|
||||
setFcn: (
|
||||
map: Partial<SetDefaultPasswordlessRegistrationMessageTextRequest.AsObject>,
|
||||
@@ -382,6 +424,20 @@ export class MessageTextsComponent implements OnInit, OnDestroy {
|
||||
{ key: 'POLICY.MESSAGE_TEXTS.CHIPS.loginnames', value: '{{.LoginNames}}' },
|
||||
{ key: 'POLICY.MESSAGE_TEXTS.CHIPS.changedate', value: '{{.ChangeDate}}' },
|
||||
],
|
||||
[MESSAGETYPES.PASSWORDCHANGE]: [
|
||||
{ key: 'POLICY.MESSAGE_TEXTS.CHIPS.preferredLoginName', value: '{{.PreferredLoginName}}' },
|
||||
{ key: 'POLICY.MESSAGE_TEXTS.CHIPS.username', value: '{{.UserName}}' },
|
||||
{ key: 'POLICY.MESSAGE_TEXTS.CHIPS.firstname', value: '{{.FirstName}}' },
|
||||
{ key: 'POLICY.MESSAGE_TEXTS.CHIPS.lastname', value: '{{.Lastname}}' },
|
||||
{ key: 'POLICY.MESSAGE_TEXTS.CHIPS.nickName', value: '{{.NickName}}' },
|
||||
{ key: 'POLICY.MESSAGE_TEXTS.CHIPS.displayName', value: '{{.DisplayName}}' },
|
||||
{ key: 'POLICY.MESSAGE_TEXTS.CHIPS.lastEmail', value: '{{.LastEmail}}' },
|
||||
{ key: 'POLICY.MESSAGE_TEXTS.CHIPS.verifiedEmail', value: '{{.VerifiedEmail}}' },
|
||||
{ key: 'POLICY.MESSAGE_TEXTS.CHIPS.lastPhone', value: '{{.LastPhone}}' },
|
||||
{ key: 'POLICY.MESSAGE_TEXTS.CHIPS.verifiedPhone', value: '{{.VerifiedPhone}}' },
|
||||
{ key: 'POLICY.MESSAGE_TEXTS.CHIPS.loginnames', value: '{{.LoginNames}}' },
|
||||
{ key: 'POLICY.MESSAGE_TEXTS.CHIPS.changedate', value: '{{.ChangeDate}}' },
|
||||
],
|
||||
};
|
||||
|
||||
public locale: string = 'en';
|
||||
@@ -435,6 +491,8 @@ export class MessageTextsComponent implements OnInit, OnDestroy {
|
||||
return this.stripDetails(this.service.getDefaultDomainClaimedMessageText(req));
|
||||
case MESSAGETYPES.PASSWORDLESS:
|
||||
return this.stripDetails(this.service.getDefaultPasswordlessRegistrationMessageText(req));
|
||||
case MESSAGETYPES.PASSWORDCHANGE:
|
||||
return this.stripDetails(this.service.getDefaultPasswordChangeMessageText(req));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -453,6 +511,9 @@ export class MessageTextsComponent implements OnInit, OnDestroy {
|
||||
return this.stripDetails((this.service as ManagementService).getCustomDomainClaimedMessageText(req));
|
||||
case MESSAGETYPES.PASSWORDLESS:
|
||||
return this.stripDetails((this.service as ManagementService).getCustomPasswordlessRegistrationMessageText(req));
|
||||
case MESSAGETYPES.PASSWORDCHANGE:
|
||||
return this.stripDetails((this.service as ManagementService).getCustomPasswordChangeMessageText(req));
|
||||
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
@@ -470,6 +531,8 @@ export class MessageTextsComponent implements OnInit, OnDestroy {
|
||||
return this.stripDetails((this.service as AdminService).getCustomDomainClaimedMessageText(req));
|
||||
case MESSAGETYPES.PASSWORDLESS:
|
||||
return this.stripDetails((this.service as AdminService).getCustomPasswordlessRegistrationMessageText(req));
|
||||
case MESSAGETYPES.PASSWORDCHANGE:
|
||||
return this.stripDetails((this.service as AdminService).getCustomPasswordChangeMessageText(req));
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
@@ -535,6 +598,8 @@ export class MessageTextsComponent implements OnInit, OnDestroy {
|
||||
return handler(
|
||||
(this.service as ManagementService).getCustomPasswordlessRegistrationMessageText(this.updateRequest),
|
||||
);
|
||||
case MESSAGETYPES.PASSWORDCHANGE:
|
||||
return handler((this.service as ManagementService).getCustomPasswordChangeMessageText(this.updateRequest));
|
||||
}
|
||||
} else if (this.serviceType === PolicyComponentServiceType.ADMIN) {
|
||||
switch (this.currentType) {
|
||||
@@ -550,6 +615,8 @@ export class MessageTextsComponent implements OnInit, OnDestroy {
|
||||
return handler((this.service as AdminService).setDefaultDomainClaimedMessageText(this.updateRequest));
|
||||
case MESSAGETYPES.PASSWORDLESS:
|
||||
return handler((this.service as AdminService).setDefaultPasswordlessRegistrationMessageText(this.updateRequest));
|
||||
case MESSAGETYPES.PASSWORDCHANGE:
|
||||
return handler((this.service as AdminService).setDefaultPasswordChangeMessageText(this.updateRequest));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -595,6 +662,8 @@ export class MessageTextsComponent implements OnInit, OnDestroy {
|
||||
return handler(
|
||||
(this.service as ManagementService).resetCustomPasswordlessRegistrationMessageTextToDefault(this.locale),
|
||||
);
|
||||
case MESSAGETYPES.PASSWORDCHANGE:
|
||||
return handler((this.service as ManagementService).resetCustomPasswordChangeMessageTextToDefault(this.locale));
|
||||
default:
|
||||
return Promise.reject();
|
||||
}
|
||||
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
<h2>{{ 'POLICY.NOTIFICATION.TITLE' | translate }}</h2>
|
||||
<p class="cnsl-secondary-text">{{ 'POLICY.NOTIFICATION.DESCRIPTION' | translate }}</p>
|
||||
|
||||
<div *ngIf="loading" class="spinner-wr">
|
||||
<mat-spinner diameter="30" color="primary"></mat-spinner>
|
||||
</div>
|
||||
|
||||
<ng-template cnslHasRole [hasRole]="['policy.delete']">
|
||||
<button
|
||||
*ngIf="serviceType === PolicyComponentServiceType.MGMT && !isDefault"
|
||||
matTooltip="{{ 'POLICY.RESET' | translate }}"
|
||||
color="warn"
|
||||
(click)="removePolicy()"
|
||||
mat-stroked-button
|
||||
>
|
||||
{{ 'POLICY.RESET' | translate }}
|
||||
</button>
|
||||
</ng-template>
|
||||
|
||||
<div class="notification-policy-card">
|
||||
<cnsl-card *ngIf="notificationData">
|
||||
<div class="notification-policy-content">
|
||||
<div class="row">
|
||||
<mat-checkbox
|
||||
class="slide-toggle"
|
||||
color="primary"
|
||||
name="hasUppercase"
|
||||
ngDefaultControl
|
||||
[(ngModel)]="notificationData.passwordChange"
|
||||
[disabled]="(['policy.write'] | hasRole | async) === false"
|
||||
>
|
||||
{{ 'POLICY.NOTIFICATION.PASSWORDCHANGE' | translate }}
|
||||
</mat-checkbox>
|
||||
</div>
|
||||
</div>
|
||||
</cnsl-card>
|
||||
</div>
|
||||
|
||||
<div class="btn-container">
|
||||
<button
|
||||
(click)="savePolicy()"
|
||||
[disabled]="(['policy.write'] | hasRole | async) === false"
|
||||
color="primary"
|
||||
type="submit"
|
||||
mat-raised-button
|
||||
>
|
||||
{{ 'ACTIONS.SAVE' | translate }}
|
||||
</button>
|
||||
</div>
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
.spinner-wr {
|
||||
margin: 0.5rem 0;
|
||||
}
|
||||
|
||||
.policy-applied-to {
|
||||
margin: -1rem 0 0 0;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.notification-policy-card {
|
||||
max-width: 400px;
|
||||
|
||||
.notification-policy-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
|
||||
.row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.btn-container {
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
|
||||
button {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
||||
|
||||
import { PasswordComplexityPolicyComponent } from './password-complexity-policy.component';
|
||||
|
||||
describe('PasswordComplexityPolicyComponent', () => {
|
||||
let component: PasswordComplexityPolicyComponent;
|
||||
let fixture: ComponentFixture<PasswordComplexityPolicyComponent>;
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [PasswordComplexityPolicyComponent],
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(PasswordComplexityPolicyComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
+177
@@ -0,0 +1,177 @@
|
||||
import { Component, Injector, Input, OnInit, Type } from '@angular/core';
|
||||
import { MatLegacyDialog as MatDialog } from '@angular/material/legacy-dialog';
|
||||
import {
|
||||
AddNotificationPolicyRequest,
|
||||
GetNotificationPolicyResponse as AdminGetNotificationPolicyResponse,
|
||||
UpdateNotificationPolicyRequest,
|
||||
} from 'src/app/proto/generated/zitadel/admin_pb';
|
||||
import {
|
||||
AddCustomNotificationPolicyRequest,
|
||||
GetNotificationPolicyResponse as MgmtGetNotificationPolicyResponse,
|
||||
} from 'src/app/proto/generated/zitadel/management_pb';
|
||||
import { NotificationPolicy } from 'src/app/proto/generated/zitadel/policy_pb';
|
||||
import { AdminService } from 'src/app/services/admin.service';
|
||||
import { ManagementService } from 'src/app/services/mgmt.service';
|
||||
import { ToastService } from 'src/app/services/toast.service';
|
||||
|
||||
import { InfoSectionType } from '../../info-section/info-section.component';
|
||||
import { WarnDialogComponent } from '../../warn-dialog/warn-dialog.component';
|
||||
import { PolicyComponentServiceType } from '../policy-component-types.enum';
|
||||
|
||||
@Component({
|
||||
selector: 'cnsl-notification-policy',
|
||||
templateUrl: './notification-policy.component.html',
|
||||
styleUrls: ['./notification-policy.component.scss'],
|
||||
})
|
||||
export class NotificationPolicyComponent implements OnInit {
|
||||
@Input() public serviceType: PolicyComponentServiceType = PolicyComponentServiceType.MGMT;
|
||||
public service!: ManagementService | AdminService;
|
||||
|
||||
public notificationData?: NotificationPolicy.AsObject = { isDefault: false, passwordChange: false };
|
||||
|
||||
public PolicyComponentServiceType: any = PolicyComponentServiceType;
|
||||
|
||||
public loading: boolean = false;
|
||||
public InfoSectionType: any = InfoSectionType;
|
||||
|
||||
public isDefault: boolean = false;
|
||||
private hasNotificationPolicy: boolean = false;
|
||||
constructor(private toast: ToastService, private injector: Injector, private dialog: MatDialog) {}
|
||||
|
||||
public ngOnInit(): void {
|
||||
switch (this.serviceType) {
|
||||
case PolicyComponentServiceType.MGMT:
|
||||
this.service = this.injector.get(ManagementService as Type<ManagementService>);
|
||||
break;
|
||||
case PolicyComponentServiceType.ADMIN:
|
||||
this.service = this.injector.get(AdminService as Type<AdminService>);
|
||||
break;
|
||||
}
|
||||
this.fetchData();
|
||||
}
|
||||
|
||||
public fetchData(): void {
|
||||
this.loading = true;
|
||||
|
||||
this.getData()
|
||||
.then((data) => {
|
||||
if (data.policy) {
|
||||
this.hasNotificationPolicy = true;
|
||||
this.notificationData = data.policy;
|
||||
this.isDefault = data.policy.isDefault;
|
||||
this.loading = false;
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
this.loading = false;
|
||||
if (error && error.code === 5) {
|
||||
console.log(error);
|
||||
this.hasNotificationPolicy = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private async getData(): Promise<
|
||||
MgmtGetNotificationPolicyResponse.AsObject | AdminGetNotificationPolicyResponse.AsObject
|
||||
> {
|
||||
switch (this.serviceType) {
|
||||
case PolicyComponentServiceType.MGMT:
|
||||
return (this.service as ManagementService).getNotificationPolicy();
|
||||
case PolicyComponentServiceType.ADMIN:
|
||||
return (this.service as AdminService).getNotificationPolicy();
|
||||
}
|
||||
}
|
||||
|
||||
public removePolicy(): void {
|
||||
if (this.service instanceof ManagementService) {
|
||||
const dialogRef = this.dialog.open(WarnDialogComponent, {
|
||||
data: {
|
||||
confirmKey: 'ACTIONS.RESET',
|
||||
cancelKey: 'ACTIONS.CANCEL',
|
||||
titleKey: 'SETTING.DIALOG.RESET.DEFAULTTITLE',
|
||||
descriptionKey: 'SETTING.DIALOG.RESET.DEFAULTDESCRIPTION',
|
||||
},
|
||||
width: '400px',
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe((resp) => {
|
||||
if (resp) {
|
||||
(this.service as ManagementService)
|
||||
.resetNotificationPolicyToDefault()
|
||||
.then(() => {
|
||||
this.toast.showInfo('POLICY.TOAST.RESETSUCCESS', true);
|
||||
this.isDefault = true;
|
||||
setTimeout(() => {
|
||||
this.fetchData();
|
||||
}, 1000);
|
||||
})
|
||||
.catch((error) => {
|
||||
this.toast.showError(error);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public savePolicy(): void {
|
||||
if (this.notificationData) {
|
||||
switch (this.serviceType) {
|
||||
case PolicyComponentServiceType.MGMT:
|
||||
if ((this.notificationData as NotificationPolicy.AsObject).isDefault) {
|
||||
const req = new AddCustomNotificationPolicyRequest();
|
||||
req.setPasswordChange(this.notificationData.passwordChange);
|
||||
(this.service as ManagementService)
|
||||
.addCustomNotificationPolicy(req)
|
||||
.then(() => {
|
||||
this.isDefault = false;
|
||||
this.toast.showInfo('POLICY.TOAST.SET', true);
|
||||
})
|
||||
.catch((error) => {
|
||||
this.toast.showError(error);
|
||||
});
|
||||
} else {
|
||||
const req = new UpdateNotificationPolicyRequest();
|
||||
req.setPasswordChange(this.notificationData.passwordChange);
|
||||
(this.service as ManagementService)
|
||||
.updateCustomNotificationPolicy(req)
|
||||
.then(() => {
|
||||
this.isDefault = false;
|
||||
this.toast.showInfo('POLICY.TOAST.SET', true);
|
||||
})
|
||||
.catch((error) => {
|
||||
this.toast.showError(error);
|
||||
});
|
||||
}
|
||||
break;
|
||||
case PolicyComponentServiceType.ADMIN:
|
||||
if (this.hasNotificationPolicy) {
|
||||
const req = new UpdateNotificationPolicyRequest();
|
||||
req.setPasswordChange(this.notificationData.passwordChange);
|
||||
(this.service as AdminService)
|
||||
.updateNotificationPolicy(req)
|
||||
.then(() => {
|
||||
this.isDefault = false;
|
||||
this.toast.showInfo('POLICY.TOAST.SET', true);
|
||||
})
|
||||
.catch((error) => {
|
||||
this.toast.showError(error);
|
||||
});
|
||||
} else {
|
||||
const req = new AddNotificationPolicyRequest();
|
||||
req.setPasswordChange(this.notificationData.passwordChange);
|
||||
(this.service as AdminService)
|
||||
.addNotificationPolicy(req)
|
||||
.then(() => {
|
||||
this.isDefault = false;
|
||||
this.hasNotificationPolicy = true;
|
||||
this.toast.showInfo('POLICY.TOAST.SET', true);
|
||||
})
|
||||
.catch((error) => {
|
||||
this.toast.showError(error);
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { MatLegacyButtonModule as MatButtonModule } from '@angular/material/legacy-button';
|
||||
import { MatLegacyCheckboxModule as MatCheckboxModule } from '@angular/material/legacy-checkbox';
|
||||
import { MatLegacyDialogModule as MatDialogModule } from '@angular/material/legacy-dialog';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatLegacyProgressSpinnerModule as MatProgressSpinnerModule } from '@angular/material/legacy-progress-spinner';
|
||||
import { MatLegacyTooltipModule as MatTooltipModule } from '@angular/material/legacy-tooltip';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { HasRoleModule } from 'src/app/directives/has-role/has-role.module';
|
||||
import { DetailLayoutModule } from 'src/app/modules/detail-layout/detail-layout.module';
|
||||
import { InputModule } from 'src/app/modules/input/input.module';
|
||||
import { HasRolePipeModule } from 'src/app/pipes/has-role-pipe/has-role-pipe.module';
|
||||
|
||||
import { CardModule } from '../../card/card.module';
|
||||
import { InfoSectionModule } from '../../info-section/info-section.module';
|
||||
import { WarnDialogModule } from '../../warn-dialog/warn-dialog.module';
|
||||
import { NotificationPolicyComponent } from './notification-policy.component';
|
||||
|
||||
@NgModule({
|
||||
declarations: [NotificationPolicyComponent],
|
||||
imports: [
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
InputModule,
|
||||
MatButtonModule,
|
||||
MatIconModule,
|
||||
HasRoleModule,
|
||||
MatDialogModule,
|
||||
MatTooltipModule,
|
||||
MatCheckboxModule,
|
||||
HasRolePipeModule,
|
||||
TranslateModule,
|
||||
WarnDialogModule,
|
||||
DetailLayoutModule,
|
||||
CardModule,
|
||||
MatProgressSpinnerModule,
|
||||
InfoSectionModule,
|
||||
],
|
||||
exports: [NotificationPolicyComponent],
|
||||
})
|
||||
export class NotificationPolicyModule {}
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
|
||||
import { PasswordComplexityPolicyComponent } from './password-complexity-policy.component';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: PasswordComplexityPolicyComponent,
|
||||
data: {
|
||||
animation: 'DetailPage',
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forChild(routes)],
|
||||
exports: [RouterModule],
|
||||
})
|
||||
export class PasswordComplexityPolicyRoutingModule {}
|
||||
-2
@@ -16,13 +16,11 @@ import { HasRolePipeModule } from 'src/app/pipes/has-role-pipe/has-role-pipe.mod
|
||||
import { CardModule } from '../../card/card.module';
|
||||
import { InfoSectionModule } from '../../info-section/info-section.module';
|
||||
import { WarnDialogModule } from '../../warn-dialog/warn-dialog.module';
|
||||
import { PasswordComplexityPolicyRoutingModule } from './password-complexity-policy-routing.module';
|
||||
import { PasswordComplexityPolicyComponent } from './password-complexity-policy.component';
|
||||
|
||||
@NgModule({
|
||||
declarations: [PasswordComplexityPolicyComponent],
|
||||
imports: [
|
||||
PasswordComplexityPolicyRoutingModule,
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
InputModule,
|
||||
|
||||
@@ -25,9 +25,14 @@
|
||||
<cnsl-idp-settings [serviceType]="serviceType"></cnsl-idp-settings>
|
||||
</ng-container>
|
||||
<ng-container *ngIf="currentSetting === 'notifications' && serviceType === PolicyComponentServiceType.ADMIN">
|
||||
<cnsl-notification-policy [serviceType]="serviceType"></cnsl-notification-policy>
|
||||
<cnsl-notification-settings [serviceType]="serviceType"></cnsl-notification-settings>
|
||||
</ng-container>
|
||||
|
||||
<ng-container *ngIf="currentSetting === 'notifications' && serviceType === PolicyComponentServiceType.MGMT">
|
||||
<cnsl-notification-policy [serviceType]="serviceType"></cnsl-notification-policy
|
||||
></ng-container>
|
||||
|
||||
<ng-container *ngIf="currentSetting === 'oidc' && serviceType === PolicyComponentServiceType.ADMIN">
|
||||
<cnsl-oidc-configuration></cnsl-oidc-configuration>
|
||||
</ng-container>
|
||||
|
||||
@@ -11,6 +11,7 @@ import { IdpSettingsModule } from '../policies/idp-settings/idp-settings.module'
|
||||
import { LoginPolicyModule } from '../policies/login-policy/login-policy.module';
|
||||
import { LoginTextsPolicyModule } from '../policies/login-texts/login-texts.module';
|
||||
import { MessageTextsPolicyModule } from '../policies/message-texts/message-texts.module';
|
||||
import { NotificationPolicyModule } from '../policies/notification-policy/notification-policy.module';
|
||||
import { NotificationSettingsModule } from '../policies/notification-settings/notification-settings.module';
|
||||
import { OIDCConfigurationModule } from '../policies/oidc-configuration/oidc-configuration.module';
|
||||
import { PasswordComplexityPolicyModule } from '../policies/password-complexity-policy/password-complexity-policy.module';
|
||||
@@ -34,6 +35,7 @@ import { SettingsListComponent } from './settings-list.component';
|
||||
PasswordLockoutPolicyModule,
|
||||
PrivateLabelingPolicyModule,
|
||||
GeneralSettingsModule,
|
||||
NotificationPolicyModule,
|
||||
IdpSettingsModule,
|
||||
PrivacyPolicyModule,
|
||||
MessageTextsPolicyModule,
|
||||
|
||||
@@ -92,6 +92,15 @@ export const NOTIFICATIONS: SidenavSetting = {
|
||||
},
|
||||
};
|
||||
|
||||
export const NOTIFICATION_POLICY: SidenavSetting = {
|
||||
id: 'notifications',
|
||||
i18nKey: 'SETTINGS.LIST.NOTIFICATIONS',
|
||||
groupI18nKey: 'SETTINGS.GROUPS.NOTIFICATIONS',
|
||||
requiredRoles: {
|
||||
[PolicyComponentServiceType.MGMT]: ['policy.read'],
|
||||
},
|
||||
};
|
||||
|
||||
export const MESSAGETEXTS: SidenavSetting = {
|
||||
id: 'messagetexts',
|
||||
i18nKey: 'SETTINGS.LIST.MESSAGETEXTS',
|
||||
|
||||
Reference in New Issue
Block a user