arreglar logica de contraseña

This commit is contained in:
Eduardo Quiros 2021-08-17 23:06:48 -06:00
parent 9f23887793
commit f4ebb8ab48
No known key found for this signature in database
GPG Key ID: B77F36C3F12720B4
3 changed files with 9 additions and 13 deletions

View File

@ -76,7 +76,6 @@ export class EncuestaCompleteComponent implements OnInit {
this.sumCalificacion = this.avgCalificacion * this.cantidadCalificaciones;
}
this.verifyPassword();
this.loadAll();
});
for (let pregunta of this.ePreguntas!) {
if (pregunta.tipo && pregunta.tipo === PreguntaCerradaTipo.SINGLE) {
@ -87,6 +86,7 @@ export class EncuestaCompleteComponent implements OnInit {
verifyPassword(): void {
if (this.encuesta!.acceso === AccesoEncuesta.PUBLIC) {
this.loadAll();
this.isLocked = false;
} else {
const modalRef = this.modalService.open(EncuestaPasswordDialogComponent, { size: 'lg', backdrop: 'static' });
@ -95,6 +95,8 @@ export class EncuestaCompleteComponent implements OnInit {
this.isLocked = reason != 'success';
if (this.isLocked) {
this.previousState();
} else {
this.loadAll();
}
});
}

View File

@ -1,12 +1,12 @@
<form class="ds-form" name="deleteForm">
<div class="" *ngIf="this.isWrong">
<p>Contraseña incorrecta</p>
</div>
<div class="modal-body">
<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">
This survey is marked as private, please enter the password
</p>
<div class="alert alert-danger" *ngIf="this.isWrong">
<p>Contraseña incorrecta</p>
</div>
<input [(ngModel)]="passwordInput" type="password" name="passwordInput" id="passwordInput" placeholder="qwerty..." />
</div>
@ -15,7 +15,7 @@
<fa-icon icon="arrow-left"></fa-icon>&nbsp;<span jhiTranslate="entity.action.cancel">Cancel</span>
</button>
<button id="jhi-confirm-delete-option" data-cy="submit" type="submit" class="ds-btn ds-btn--primary" (click)="submitPassword()">
<button class="ds-btn ds-btn--primary" (click)="submitPassword()">
<span jhiTranslate="entity.action.submit">Submit</span>
</button>
</div>

View File

@ -1,5 +1,4 @@
import { Component, OnInit } from '@angular/core';
import { FormBuilder, Validators } from '@angular/forms';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { IEncuesta } from '../encuesta.model';
@ -9,21 +8,16 @@ import { IEncuesta } from '../encuesta.model';
styleUrls: ['./encuesta-password-dialog.component.scss'],
})
export class EncuestaPasswordDialogComponent implements OnInit {
passwordForm = this.fb.group({
password: [null, [Validators.required]],
});
encuesta?: IEncuesta;
isWrong?: boolean;
passwordInput?: string;
constructor(protected activeModal: NgbActiveModal, protected fb: FormBuilder) {}
constructor(protected activeModal: NgbActiveModal) {}
ngOnInit(): void {}
submitPassword() {
const password = this.passwordForm.get(['password'])!.value;
if (this.passwordForm.valid && password === this.encuesta!.contrasenna) {
if (this.passwordInput != undefined && this.passwordInput === this.encuesta!.contrasenna) {
this.activeModal.close('success');
} else {
this.isWrong = true;