agregar logica de evaluación de contraseña

This commit is contained in:
Eduardo Quiros 2021-08-03 23:07:27 -06:00
parent 2ae9407d7a
commit 44a83ba01a
No known key found for this signature in database
GPG Key ID: B77F36C3F12720B4
2 changed files with 10 additions and 6 deletions

View File

@ -1,10 +1,13 @@
<form class="ds-form" [formGroup]="passwordForm" name="deleteForm" (ngSubmit)="submitPassword()"> <form class="ds-form" [formGroup]="passwordForm" name="deleteForm" (ngSubmit)="submitPassword()">
<div *ngIf="this.isWrong">
<p>Contraseña incorrecta</p>
</div>
<div class="modal-body"> <div class="modal-body">
<p class="ds-title--small" jhiTranslate="dataSurveyApp.encuesta.password.title">Enter password</p> <p class="ds-title--small" jhiTranslate="dataSurveyApp.encuesta.password.title">Enter password</p>
<p class="ds-subtitle" id="jhi-delete-encuesta-heading" jhiTranslate="dataSurveyApp.encuesta.password.text"> <p class="ds-subtitle" id="jhi-delete-encuesta-heading" jhiTranslate="dataSurveyApp.encuesta.password.text">
This survey is marked as private, please enter the password This survey is marked as private, please enter the password
</p> </p>
<input type="password" name="passwordInput" id="passwordInput" placeholder="qwerty..." /> <input [(ngModel)]="passwordInput" type="password" name="passwordInput" id="passwordInput" placeholder="qwerty..." />
</div> </div>
<div class="modal-footer"> <div class="modal-footer">

View File

@ -12,24 +12,25 @@ export class EncuestaPasswordDialogComponent implements OnInit {
passwordForm = this.fb.group({ passwordForm = this.fb.group({
password: [null, [Validators.required]], password: [null, [Validators.required]],
}); });
isEval: boolean = false;
encuesta?: IEncuesta; encuesta?: IEncuesta;
isWrong?: boolean;
passwordInput?: string;
constructor(protected activeModal: NgbActiveModal, protected fb: FormBuilder) {} constructor(protected activeModal: NgbActiveModal, protected fb: FormBuilder) {}
ngOnInit(): void {} ngOnInit(): void {}
submitPassword() { submitPassword() {
this.isEval = true;
const password = this.passwordForm.get(['password'])!.value; const password = this.passwordForm.get(['password'])!.value;
if (this.passwordForm.valid && password === this.encuesta!.contrasenna) { if (this.passwordForm.valid && password === this.encuesta!.contrasenna) {
this.isEval = false; this.activeModal.close('success');
//navegar a la vara } else {
this.isWrong = true;
} }
} }
cancel(): void { cancel(): void {
this.activeModal.dismiss(); this.activeModal.close('cancel');
} }
} }