a5cb52fb423fcee70fd869f00acf6e292b32c44bf0a329c67a93c33f80a5808b.json 11 KB

1
  1. {"ast":null,"code":"import { __decorate } from \"tslib\";\nimport __NG_CLI_RESOURCE__0 from \"./reset-password.component.html?ngResource\";\nimport __NG_CLI_RESOURCE__1 from \"./reset-password.component.scss?ngResource\";\nimport { MatDialog } from '@angular/material/dialog';\nimport { ConfirmMessageComponent } from './../../shared/confirm-message/confirm-message.component';\nimport { MatSnackBar } from '@angular/material/snack-bar';\nimport { Router, ActivatedRoute } from '@angular/router';\nimport { AuthService } from './../../../services/auth.service';\nimport { Validators, FormBuilder } from '@angular/forms';\nimport { Component } from '@angular/core';\nimport { MustMatch } from '../../shared/validator/confirm-password.validator';\nlet ResetPasswordComponent = 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.ctorParameters = () => [{\n type: Router\n }, {\n type: MatSnackBar\n }, {\n type: ActivatedRoute\n }, {\n type: AuthService\n }, {\n type: FormBuilder\n }, {\n type: MatDialog\n }];\n};\nResetPasswordComponent = __decorate([Component({\n selector: 'app-reset-password',\n template: __NG_CLI_RESOURCE__0,\n styles: [__NG_CLI_RESOURCE__1]\n})], ResetPasswordComponent);\nexport { ResetPasswordComponent };","map":{"version":3,"names":["MatDialog","ConfirmMessageComponent","MatSnackBar","Router","ActivatedRoute","AuthService","Validators","FormBuilder","Component","MustMatch","ResetPasswordComponent","constructor","router","snackBar","activatedRoute","authService","formBuilder","dialog","submitted","loading","ngOnInit","createForm","subscription","params","subscribe","token","ngOnDestroy","unsubscribe","formGroup","group","password","required","checkPassword","confirmPassword","validator","control","enteredPassword","value","passwordCheck","test","getErrorPassword","get","hasError","getErrorConfirmPassword","f","controls","ResetPassword","invalid","data","resetPassword","console","log","openDialog","err","openSnackBar","error","message","dialogRef","open","width","response","afterClosed","navigate","_","__decorate","selector","template","__NG_CLI_RESOURCE__0"],"sources":["C:\\FatboarProject\\angular-client\\src\\app\\components\\login\\reset-password\\reset-password.component.ts"],"sourcesContent":["import { MatDialog } from '@angular/material/dialog';\r\nimport { ConfirmMessageComponent } from './../../shared/confirm-message/confirm-message.component';\r\nimport { MatSnackBar } from '@angular/material/snack-bar';\r\nimport { Router, ActivatedRoute } from '@angular/router';\r\nimport { AuthService } from './../../../services/auth.service';\r\nimport { Validators, FormGroup, FormBuilder, FormControl } from '@angular/forms';\r\nimport { Component, OnInit } from '@angular/core';\r\nimport { MustMatch } from '../../shared/validator/confirm-password.validator';\r\n\r\n\r\n\r\n@Component({\r\n selector: 'app-reset-password',\r\n templateUrl: './reset-password.component.html',\r\n styleUrls: ['./reset-password.component.scss']\r\n})\r\nexport class ResetPasswordComponent implements OnInit {\r\n\r\n constructor( public router: Router, public snackBar: MatSnackBar, private activatedRoute: ActivatedRoute, \r\n private authService : AuthService, private formBuilder: FormBuilder, public dialog: MatDialog)\r\n { }\r\n\r\n formGroup: FormGroup;\r\n submitted = false;\r\n loading = false;\r\n token ;\r\n\r\n private subscription : any;\r\n\r\n\r\n ngOnInit(): void {\r\n this.createForm(); \r\n this.subscription = this.activatedRoute.params.subscribe( params => {\r\n this.token = params.token\r\n })\r\n }\r\n\r\n\r\n ngOnDestroy() {\r\n this.subscription.unsubscribe();\r\n }\r\n\r\n createForm() {\r\n \r\n this.formGroup = this.formBuilder.group({\r\n password: ['', [Validators.required, this.checkPassword]],\r\n confirmPassword:['', Validators.required]\r\n }, {\r\n validator: MustMatch('password', 'confirmPassword')\r\n });\r\n}\r\n\r\n\r\n\r\n\r\n\r\n checkPassword(control) {\r\n let enteredPassword = control.value\r\n let passwordCheck = /^(?=.*[a-z])(?=.{6,})/;\r\n return (!passwordCheck.test(enteredPassword) && enteredPassword) ? { 'requirements': true } : null;\r\n }\r\n\r\n getErrorPassword() {\r\n return this.formGroup.get('password').hasError('required') ? 'Mot de passe requis' :\r\n this.formGroup.get('password').hasError('requirements') ? \r\n 'Le mot de passe doit comporter au moins 8 caractères, une lettre majuscule' : '';\r\n }\r\n\r\n\r\n getErrorConfirmPassword() {\r\n return this.formGroup.get('confirmPassword').hasError('required') ? 'Confirmation mot de passe requise' :\r\n this.formGroup.hasError('MustMatch') ? \r\n '' : 'Les mots de passe saisis ne sont pas identiques';\r\n }\r\n\r\n\r\n \r\n get f() { return this.formGroup.controls; }\r\n\r\n \r\n\r\n // login\r\n ResetPassword(){\r\n\r\n this.submitted = true;\r\n if (this.formGroup.invalid) {\r\n return;\r\n }\r\n this.loading = true;\r\n let data = {'password': this.formGroup.value.password, 'resetLink': this.token }\r\n\r\n this.authService.resetPassword(data).subscribe(\r\n data => {\r\n console.log(data)\r\n this.loading = false;\r\n this.openDialog(data)\r\n },\r\n err => {\r\n this.loading = false;\r\n this.authService.openSnackBar(err.error.message)\r\n });\r\n\r\n }\r\n\r\n openDialog(data) {\r\n const dialogRef =\r\n this.dialog.open(ConfirmMessageComponent, {\r\n width: '38%',\r\n data: {\r\n response: data\r\n }\r\n });\r\n dialogRef.afterClosed().subscribe(() => {\r\n this.router.navigate(['/login']);\r\n });\r\n }\r\n\r\n\r\n}"],"mappings":";;;AAAA,SAASA,SAAS,QAAQ,0BAA0B;AACpD,SAASC,uBAAuB,QAAQ,0DAA0D;AAClG,SAASC,WAAW,QAAQ,6BAA6B;AACzD,SAASC,MAAM,EAAEC,cAAc,QAAQ,iBAAiB;AACxD,SAASC,WAAW,QAAQ,kCAAkC;AAC9D,SAASC,UAAU,EAAaC,WAAW,QAAqB,gBAAgB;AAChF,SAASC,SAAS,QAAgB,eAAe;AACjD,SAASC,SAAS,QAAQ,mDAAmD;AAStE,IAAMC,sBAAsB,GAA5B,MAAMA,sBAAsB;EAEjCC,YAAoBC,MAAc,EAASC,QAAqB,EAAUC,cAA8B,EAC9FC,WAAyB,EAAUC,WAAwB,EAAUC,MAAiB;IAD5E,KAAAL,MAAM,GAANA,MAAM;IAAiB,KAAAC,QAAQ,GAARA,QAAQ;IAAuB,KAAAC,cAAc,GAAdA,cAAc;IAC9E,KAAAC,WAAW,GAAXA,WAAW;IAAwB,KAAAC,WAAW,GAAXA,WAAW;IAAuB,KAAAC,MAAM,GAANA,MAAM;IAInF,KAAAC,SAAS,GAAG,KAAK;IACjB,KAAAC,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