feat(console): set email verified on change, user create (#2847)

* feat: set email verified on change

* user create
This commit is contained in:
Max Peintner
2021-12-15 10:23:53 +00:00
committed by GitHub
parent a533872c66
commit fb43b13232
16 changed files with 289 additions and 251 deletions
@@ -27,11 +27,11 @@
.btn-container {
display: flex;
justify-content: flex-end;
margin: 0 -.5rem;
margin: 0 -0.5rem;
button {
border-radius: .5rem;
margin: 0 .5rem;
border-radius: 0.5rem;
margin: 0 0.5rem;
}
}
@@ -39,11 +39,11 @@
display: flex;
flex-wrap: wrap;
align-items: stretch;
margin: -1.5rem -.5rem;
margin: -1.5rem -0.5rem;
.app-card {
flex: 1;
margin: .5rem;
margin: 0.5rem;
}
}
@@ -55,6 +55,7 @@
.resendemail {
margin-right: 1rem;
margin-top: 0.5rem;
}
.side-padding {
@@ -227,9 +227,9 @@ export class AuthUserDetailComponent implements OnDestroy {
width: '400px',
});
dialogRefPhone.afterClosed().subscribe((resp) => {
if (resp) {
this.savePhone(resp);
dialogRefPhone.afterClosed().subscribe((resp: { value: string; isVerified: boolean }) => {
if (resp && resp.value) {
this.savePhone(resp.value);
}
});
break;
@@ -247,9 +247,9 @@ export class AuthUserDetailComponent implements OnDestroy {
width: '400px',
});
dialogRefEmail.afterClosed().subscribe((resp) => {
if (resp) {
this.saveEmail(resp);
dialogRefEmail.afterClosed().subscribe((resp: { value: string; isVerified: boolean }) => {
if (resp && resp.value) {
this.saveEmail(resp.value);
}
});
break;
@@ -1,22 +1,32 @@
<h1 mat-dialog-title>
<span class="title">{{data.titleKey | translate}}</span>
<span class="title">{{data.titleKey | translate}}</span>
</h1>
<p class="desc">{{data.descriptionKey | translate}}</p>
<div mat-dialog-content>
<cnsl-form-field class="formfield">
<cnsl-label>{{data.labelKey | translate }} <span *ngIf="isPhone && phoneCountry">({{ phoneCountry }})</span>
</cnsl-label>
<input [formControl]="valueControl" cnslInput
(keydown.enter)="valueControl.valid ? closeDialogWithValue() : null" />
</cnsl-form-field>
<cnsl-form-field class="formfield">
<cnsl-label>{{data.labelKey | translate }} <span *ngIf="isPhone && phoneCountry">({{ phoneCountry }})</span>
</cnsl-label>
<input [formControl]="valueControl" cnslInput
(keydown.enter)="valueControl.valid ? closeDialogWithValue() : null" />
</cnsl-form-field>
<ng-container *ngIf="data.type === EditDialogType.EMAIL && data.isVerifiedTextKey">
<mat-checkbox class="verified-checkbox" [(ngModel)]="isVerified">
{{data.isVerifiedTextKey |
translate}}
</mat-checkbox>
<cnsl-info-section class="full-width desc">
<span>{{data.isVerifiedTextDescKey | translate}}</span>
</cnsl-info-section>
</ng-container>
</div>
<div mat-dialog-actions class="action">
<button cdkFocusInitial color="primary" mat-button class="ok-button" (click)="closeDialog()">
{{data.cancelKey | translate}}
</button>
<button cdkFocusInitial color="primary" mat-button class="ok-button" (click)="closeDialog()">
{{data.cancelKey | translate}}
</button>
<button [disabled]="valueControl.invalid" cdkFocusInitial color="primary" mat-raised-button class="ok-button"
(click)="closeDialogWithValue()">
{{data.confirmKey | translate}}
</button>
<button [disabled]="valueControl.invalid" cdkFocusInitial color="primary" mat-raised-button class="ok-button"
(click)="closeDialogWithValue()">
{{data.confirmKey | translate}}
</button>
</div>
@@ -2,6 +2,10 @@
width: 100%;
}
.verified-checkbox {
margin-top: 1.5rem;
}
.desc {
font-size: 14px;
color: var(--grey);
@@ -12,10 +16,10 @@
justify-content: flex-end;
.ok-button {
margin-left: .5rem;
margin-left: 0.5rem;
}
button {
border-radius: .5rem;
border-radius: 0.5rem;
}
}
@@ -15,16 +15,17 @@ export enum EditDialogType {
})
export class EditDialogComponent {
public isPhone: boolean = false;
public isVerified: boolean = false;
public phoneCountry: string = 'CH';
public valueControl: FormControl = new FormControl(['', [Validators.required]]);
constructor(public dialogRef: MatDialogRef<EditDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: any) {
public EditDialogType: any = EditDialogType;
constructor(public dialogRef: MatDialogRef<EditDialogComponent>, @Inject(MAT_DIALOG_DATA) public data: any) {
this.valueControl.setValue(data.value);
if (data.type === EditDialogType.PHONE) {
this.isPhone = true;
}
this.valueControl.valueChanges.subscribe(value => {
this.valueControl.valueChanges.subscribe((value) => {
if (value && value.length > 1) {
this.changeValue(value);
}
@@ -53,6 +54,6 @@ export class EditDialogComponent {
}
closeDialogWithValue(): void {
this.dialogRef.close(this.valueControl.value);
this.dialogRef.close({ value: this.valueControl.value, isVerified: this.isVerified });
}
}
@@ -19,7 +19,7 @@
}
p {
margin: .5rem 0;
margin: 0.5rem 0;
font-size: 14px;
color: var(--grey);
}
@@ -30,13 +30,13 @@
}
.actions-trigger {
margin-top: .25rem;
margin-top: 0.25rem;
display: flex;
align-items: center;
.icon {
margin-left: .5rem;
margin-right: -.5rem;
margin-left: 0.5rem;
margin-right: -0.5rem;
}
}
}
@@ -66,3 +66,7 @@
.side-padding {
padding-top: 1rem;
}
.resendemail {
margin-top: 0.5rem;
}
@@ -229,10 +229,10 @@ export class UserDetailComponent implements OnInit {
});
}
public saveEmail(email: string): void {
public saveEmail(email: string, isVerified: boolean): void {
if (this.user.id && email) {
this.mgmtUserService
.updateHumanEmail(this.user.id, email)
.updateHumanEmail(this.user.id, email, isVerified)
.then(() => {
this.toast.showInfo('USER.TOAST.EMAILSAVED', true);
if (this.user.state === UserState.USER_STATE_INITIAL) {
@@ -355,9 +355,9 @@ export class UserDetailComponent implements OnInit {
width: '400px',
});
dialogRefPhone.afterClosed().subscribe((resp) => {
if (resp) {
this.savePhone(resp);
dialogRefPhone.afterClosed().subscribe((resp: { value: string; isVerified: boolean }) => {
if (resp && resp.value) {
this.savePhone(resp.value);
}
});
break;
@@ -369,15 +369,17 @@ export class UserDetailComponent implements OnInit {
labelKey: 'ACTIONS.NEWVALUE',
titleKey: 'USER.LOGINMETHODS.EMAIL.EDITTITLE',
descriptionKey: 'USER.LOGINMETHODS.EMAIL.EDITDESC',
isVerifiedTextKey: 'USER.LOGINMETHODS.EMAIL.ISVERIFIED',
isVerifiedTextDescKey: 'USER.LOGINMETHODS.EMAIL.ISVERIFIEDDESC',
value: this.user.human?.email?.email,
type: EditDialogType.EMAIL,
},
width: '400px',
});
dialogRefEmail.afterClosed().subscribe((resp) => {
if (resp) {
this.saveEmail(resp);
dialogRefEmail.afterClosed().subscribe((resp: { value: string; isVerified: boolean }) => {
if (resp && resp.value) {
this.saveEmail(resp.value, resp.isVerified);
}
});
break;