| 1 |
- {"ast":null,"code":"import { ConfirmMessageComponent } from './../../shared/confirm-message/confirm-message.component';\nimport { Validators } from '@angular/forms';\nimport { MustMatch } from '../../shared/validator/confirm-password.validator';\nimport * as i0 from \"@angular/core\";\nimport * as i1 from \"@angular/router\";\nimport * as i2 from \"@angular/material/snack-bar\";\nimport * as i3 from \"./../../../services/auth.service\";\nimport * as i4 from \"@angular/forms\";\nimport * as i5 from \"@angular/material/dialog\";\nimport * as i6 from \"@angular/common\";\nimport * as i7 from \"@angular/material/card\";\nimport * as i8 from \"@angular/material/button\";\nimport * as i9 from \"@angular/material/input\";\nimport * as i10 from \"@angular/material/form-field\";\nimport * as i11 from \"@angular/material/progress-bar\";\nfunction ResetPasswordComponent_mat_progress_bar_3_Template(rf, ctx) {\n if (rf & 1) {\n i0.ɵɵelement(0, \"mat-progress-bar\", 13);\n }\n}\nfunction ResetPasswordComponent_mat_error_14_Template(rf, ctx) {\n if (rf & 1) {\n i0.ɵɵelementStart(0, \"mat-error\");\n i0.ɵɵtext(1);\n i0.ɵɵelementEnd();\n }\n if (rf & 2) {\n const ctx_r1 = i0.ɵɵnextContext();\n i0.ɵɵadvance(1);\n i0.ɵɵtextInterpolate1(\" \", ctx_r1.getErrorPassword(), \" \");\n }\n}\nfunction ResetPasswordComponent_mat_error_18_Template(rf, ctx) {\n if (rf & 1) {\n i0.ɵɵelementStart(0, \"mat-error\");\n i0.ɵɵtext(1);\n i0.ɵɵelementEnd();\n }\n if (rf & 2) {\n const ctx_r2 = i0.ɵɵnextContext();\n i0.ɵɵadvance(1);\n i0.ɵɵtextInterpolate1(\" \", ctx_r2.getErrorConfirmPassword(), \" \");\n }\n}\nexport let ResetPasswordComponent = /*#__PURE__*/(() => {\n class ResetPasswordComponent {\n constructor(router, snackBar, activatedRoute, authService, formBuilder, dialog) {\n this.router = router;\n this.snackBar = snackBar;\n this.activatedRoute = activatedRoute;\n this.authService = authService;\n this.formBuilder = formBuilder;\n this.dialog = dialog;\n this.submitted = false;\n this.loading = false;\n }\n ngOnInit() {\n this.createForm();\n this.subscription = this.activatedRoute.params.subscribe(params => {\n this.token = params.token;\n });\n }\n ngOnDestroy() {\n this.subscription.unsubscribe();\n }\n createForm() {\n this.formGroup = this.formBuilder.group({\n password: ['', [Validators.required, this.checkPassword]],\n confirmPassword: ['', Validators.required]\n }, {\n validator: MustMatch('password', 'confirmPassword')\n });\n }\n checkPassword(control) {\n let enteredPassword = control.value;\n let passwordCheck = /^(?=.*[a-z])(?=.{6,})/;\n return !passwordCheck.test(enteredPassword) && enteredPassword ? {\n 'requirements': true\n } : null;\n }\n getErrorPassword() {\n return this.formGroup.get('password').hasError('required') ? 'Mot de passe requis' : this.formGroup.get('password').hasError('requirements') ? 'Le mot de passe doit comporter au moins 8 caractères, une lettre majuscule' : '';\n }\n getErrorConfirmPassword() {\n return this.formGroup.get('confirmPassword').hasError('required') ? 'Confirmation mot de passe requise' : this.formGroup.hasError('MustMatch') ? '' : 'Les mots de passe saisis ne sont pas identiques';\n }\n get f() {\n return this.formGroup.controls;\n }\n // login\n ResetPassword() {\n this.submitted = true;\n if (this.formGroup.invalid) {\n return;\n }\n this.loading = true;\n let data = {\n 'password': this.formGroup.value.password,\n 'resetLink': this.token\n };\n this.authService.resetPassword(data).subscribe(data => {\n console.log(data);\n this.loading = false;\n this.openDialog(data);\n }, err => {\n this.loading = false;\n this.authService.openSnackBar(err.error.message);\n });\n }\n openDialog(data) {\n const dialogRef = this.dialog.open(ConfirmMessageComponent, {\n width: '38%',\n data: {\n response: data\n }\n });\n dialogRef.afterClosed().subscribe(() => {\n this.router.navigate(['/login']);\n });\n }\n static #_ = this.ɵfac = function ResetPasswordComponent_Factory(t) {\n return new (t || ResetPasswordComponent)(i0.ɵɵdirectiveInject(i1.Router), i0.ɵɵdirectiveInject(i2.MatSnackBar), i0.ɵɵdirectiveInject(i1.ActivatedRoute), i0.ɵɵdirectiveInject(i3.AuthService), i0.ɵɵdirectiveInject(i4.FormBuilder), i0.ɵɵdirectiveInject(i5.MatDialog));\n };\n static #_2 = this.ɵcmp = /*@__PURE__*/i0.ɵɵdefineComponent({\n type: ResetPasswordComponent,\n selectors: [[\"app-reset-password\"]],\n decls: 22,\n vars: 4,\n consts: [[1, \"container\", \"navtop\"], [1, \"row\", \"justify-content-center\"], [1, \"col-10\", \"col-lg-7\", 2, \"border-radius\", \"30px\"], [\"class\", \"col-12\", \"mode\", \"indeterminate\", 4, \"ngIf\"], [3, \"formGroup\", \"ngSubmit\"], [1, \"row\", \"justify-content-center\", \"mt-2\"], [1, \"text-center\"], [1, \"col-10\"], [\"matInput\", \"\", \"placeholder\", \"Nouveau mot de passe\", \"type\", \"password\", \"formControlName\", \"password\", \"required\", \"\"], [4, \"ngIf\"], [\"matInput\", \"\", \"placeholder\", \"Confirmer votre mot de passe\", \"type\", \"password\", \"formControlName\", \"confirmPassword\", \"required\", \"\"], [1, \"row\", \"justify-content-center\", \"my-3\"], [\"mat-raised-button\", \"\", \"color\", \"primary\", \"type\", \"submit\", 1, \"col-8\", \"col-md-4\", \"color-theme\"], [\"mode\", \"indeterminate\", 1, \"col-12\"]],\n template: function ResetPasswordComponent_Template(rf, ctx) {\n if (rf & 1) {\n i0.ɵɵelementStart(0, \"div\", 0)(1, \"div\", 1)(2, \"mat-card\", 2);\n i0.ɵɵtemplate(3, ResetPasswordComponent_mat_progress_bar_3_Template, 1, 0, \"mat-progress-bar\", 3);\n i0.ɵɵelementStart(4, \"mat-card-content\")(5, \"form\", 4);\n i0.ɵɵlistener(\"ngSubmit\", function ResetPasswordComponent_Template_form_ngSubmit_5_listener() {\n return ctx.ResetPassword();\n });\n i0.ɵɵelementStart(6, \"h1\", 5)(7, \"b\");\n i0.ɵɵtext(8, \"R\\u00E9initialiser votre mot de passe\");\n i0.ɵɵelementEnd()();\n i0.ɵɵelementStart(9, \"h3\", 6);\n i0.ɵɵtext(10, \"Renseignez votre nouveau mot de passe ci-dessous.\");\n i0.ɵɵelementEnd();\n i0.ɵɵelementStart(11, \"div\", 1)(12, \"mat-form-field\", 7);\n i0.ɵɵelement(13, \"input\", 8);\n i0.ɵɵtemplate(14, ResetPasswordComponent_mat_error_14_Template, 2, 1, \"mat-error\", 9);\n i0.ɵɵelementEnd()();\n i0.ɵɵelementStart(15, \"div\", 1)(16, \"mat-form-field\", 7);\n i0.ɵɵelement(17, \"input\", 10);\n i0.ɵɵtemplate(18, ResetPasswordComponent_mat_error_18_Template, 2, 1, \"mat-error\", 9);\n i0.ɵɵelementEnd()();\n i0.ɵɵelementStart(19, \"div\", 11)(20, \"button\", 12);\n i0.ɵɵtext(21, \" Envoyer\");\n i0.ɵɵelementEnd()()()()()()();\n }\n if (rf & 2) {\n i0.ɵɵadvance(3);\n i0.ɵɵproperty(\"ngIf\", ctx.loading);\n i0.ɵɵadvance(2);\n i0.ɵɵproperty(\"formGroup\", ctx.formGroup);\n i0.ɵɵadvance(9);\n i0.ɵɵproperty(\"ngIf\", !ctx.formGroup.controls[\"password\"].valid || ctx.formGroup.controls[\"password\"].touched);\n i0.ɵɵadvance(4);\n i0.ɵɵproperty(\"ngIf\", !ctx.formGroup.controls[\"password\"].valid || ctx.formGroup.controls[\"password\"].touched);\n }\n },\n dependencies: [i6.NgIf, i7.MatCard, i7.MatCardContent, i8.MatButton, i9.MatInput, i10.MatFormField, i10.MatError, i11.MatProgressBar, i4.ɵNgNoValidate, i4.DefaultValueAccessor, i4.NgControlStatus, i4.NgControlStatusGroup, i4.RequiredValidator, i4.FormGroupDirective, i4.FormControlName],\n styles: [\".navtop[_ngcontent-%COMP%]{margin-top:9em;margin-bottom:3.8em}.marginButton[_ngcontent-%COMP%]{margin-bottom:0!important}\"]\n });\n }\n return ResetPasswordComponent;\n})();","map":null,"metadata":{},"sourceType":"module","externalDependencies":[]}
|