Commit d16d2947 by Matteo

Fix validazione doppia password

parent 91de80e7
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
{{ 'registrazione' | translate }} {{ 'registrazione' | translate }}
</div> </div>
</div> </div>
<ion-grid class="transparent bc-grid"> <ion-grid class="transparent bc-grid">
<ion-row class="transparent"> <ion-row class="transparent">
<ion-col align-self-end size-md="6" size-lg="6" size-xs="12" class="transparent"> <ion-col align-self-end size-md="6" size-lg="6" size-xs="12" class="transparent">
<div class="body-form body-img12"> <div class="body-form body-img12">
...@@ -55,10 +55,10 @@ ...@@ -55,10 +55,10 @@
<ion-input formControlName="cellulare" type="tel" placeholder="{{ 'cellulare' | translate }}" ngModel required></ion-input> <ion-input formControlName="cellulare" type="tel" placeholder="{{ 'cellulare' | translate }}" ngModel required></ion-input>
</ion-item> </ion-item>
<ion-item> <ion-item>
<ion-input formControlName="password" type="password" placeholder="{{ 'pwd' | translate }}" ngModel required></ion-input> <ion-input formControlName="newpassword" type="password" placeholder="{{ 'pwd' | translate }}" ngModel required></ion-input>
</ion-item> </ion-item>
<ion-item> <ion-item>
<ion-input formControlName="passwordbis" type="password" placeholder="{{ 'repeat_pwd' | translate }}" ngModel required></ion-input> <ion-input formControlName="newpasswordbis" type="password" placeholder="{{ 'repeat_pwd' | translate }}" ngModel required></ion-input>
</ion-item> </ion-item>
</div> </div>
<div padding> <div padding>
......
...@@ -79,12 +79,12 @@ export class RegistrazionePage implements OnInit { ...@@ -79,12 +79,12 @@ export class RegistrazionePage implements OnInit {
cellulare: new FormControl('', Validators.compose([ cellulare: new FormControl('', Validators.compose([
Validators.pattern('^[0-9]+$'), Validators.pattern('^[0-9]+$'),
])), ])),
password: new FormControl('', Validators.compose([ newpassword: new FormControl('', Validators.compose([
Validators.minLength(5), Validators.minLength(5),
Validators.required, Validators.required,
Validators.pattern('^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])[a-zA-Z0-9]+$') //this is for the letters (both uppercase and lowercase) and numbers validation Validators.pattern('^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])[a-zA-Z0-9]+$') //this is for the letters (both uppercase and lowercase) and numbers validation
])), ])),
passwordbis: new FormControl('', Validators.compose([ newpasswordbis: new FormControl('', Validators.compose([
Validators.required Validators.required
])) ]))
},(formGroup: FormGroup) => { },(formGroup: FormGroup) => {
......
...@@ -158,7 +158,7 @@ export class AuthService { ...@@ -158,7 +158,7 @@ export class AuthService {
registra(value) : Observable<ErrorResponse>{ registra(value) : Observable<ErrorResponse>{
this.tipoStruttura = environment.struttura; this.tipoStruttura = environment.struttura;
var param = UtilService.encodeBody({nome: value.nome, cognome: value.cognome, email: value.email, cellulare: value.cellulare, password: value.password, tipostruttura: this.tipoStruttura}); var param = UtilService.encodeBody({nome: value.nome, cognome: value.cognome, email: value.email, cellulare: value.cellulare, password: value.newpassword, tipostruttura: this.tipoStruttura});
this.clientiSalvati = false; this.clientiSalvati = false;
return this.httpClient.post<ErrorResponse>(this.httpClientDataService.BASE_ADDRESS+'/autenticazione/registrazione.do', param, this.httpClientDataService.httpOptions) return this.httpClient.post<ErrorResponse>(this.httpClientDataService.BASE_ADDRESS+'/autenticazione/registrazione.do', param, this.httpClientDataService.httpOptions)
.pipe( .pipe(
......
...@@ -8,20 +8,22 @@ static equals = (newpasswordControl: AbstractControl): ValidatorFn => { ...@@ -8,20 +8,22 @@ static equals = (newpasswordControl: AbstractControl): ValidatorFn => {
return (passwordBisControl: AbstractControl): {[key: string]: boolean} => { return (passwordBisControl: AbstractControl): {[key: string]: boolean} => {
if(newpasswordControl.value == passwordBisControl.value) { if(newpasswordControl.value == passwordBisControl.value) {
return { return {
equals: true equals: false
}; };
} }
else return null; else return {
equals: true
};;
}; };
} }
static areEqual(formGroup: FormGroup) { static areEqual(formGroup: FormGroup) {
let val; let val;
let valid = true; let valid = true;
for (let key in formGroup.controls) { for (let key in formGroup.controls) {
if (formGroup.controls.hasOwnProperty(key)) { if (formGroup.controls.hasOwnProperty(key)) {
if(key == "oldpassword") continue; if(key != "newpassword" && key != "newpasswordbis") continue;
let control: FormControl = <FormControl>formGroup.controls[key]; let control: FormControl = <FormControl>formGroup.controls[key];
if (val === undefined) { if (val === undefined) {
val = control.value val = control.value
...@@ -33,14 +35,12 @@ static areEqual(formGroup: FormGroup) { ...@@ -33,14 +35,12 @@ static areEqual(formGroup: FormGroup) {
} }
} }
} }
if (!valid) /*{ if (!valid) {
return null; //return null;
return { return {
areEqual: false areEqual: true
} }
}*/
return {
areEqual: true
} }
return null;
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment