Merge pull request #38 from Quantum-P3/feature/US-08
fix validaciones password
This commit is contained in:
commit
9f731e1003
|
@ -305,19 +305,35 @@
|
||||||
<div class="row mb-3 pb-3" style="border-bottom: 1px solid #e7ebf3">
|
<div class="row mb-3 pb-3" style="border-bottom: 1px solid #e7ebf3">
|
||||||
<div
|
<div
|
||||||
class="alert alert-danger"
|
class="alert alert-danger"
|
||||||
*ngIf="errorPassword && !doNotMatch && !successPassword"
|
*ngIf="errorPassword && !doNotMatch && !successPassword && !samePassword"
|
||||||
jhiTranslate="global.messages.info.authenticated.passwordForm"
|
jhiTranslate="global.messages.info.authenticated.passwordForm"
|
||||||
data-cy="loginError"
|
data-cy="loginError"
|
||||||
></div>
|
></div>
|
||||||
|
|
||||||
<div *ngIf="successPassword" class="alert alert-success alert-dismissible fade show" role="alert">
|
<div
|
||||||
|
*ngIf="successPassword && !errorPassword && !samePassword && !doNotMatch"
|
||||||
|
class="alert alert-success alert-dismissible fade show"
|
||||||
|
role="alert"
|
||||||
|
>
|
||||||
Sus contraseña fue actualizada de manera exitosa
|
Sus contraseña fue actualizada de manera exitosa
|
||||||
<!-- <button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
<!-- <button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||||||
<span aria-hidden="true">×</span>
|
<span aria-hidden="true">×</span>
|
||||||
</button>-->
|
</button>-->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="alert alert-danger" *ngIf="doNotMatch && !successPassword" jhiTranslate="global.messages.error.dontmatch">
|
<div
|
||||||
|
class="alert alert-danger"
|
||||||
|
*ngIf="doNotMatch && !successPassword && !errorPassword"
|
||||||
|
jhiTranslate="global.messages.error.dontmatch"
|
||||||
|
>
|
||||||
|
The password and its confirmation do not match!
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="alert alert-danger"
|
||||||
|
*ngIf="samePassword && !successPassword && !errorPassword && !doNotMatch"
|
||||||
|
jhiTranslate="global.messages.error.samePassword"
|
||||||
|
>
|
||||||
The password and its confirmation do not match!
|
The password and its confirmation do not match!
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -477,7 +493,7 @@
|
||||||
type="submit"
|
type="submit"
|
||||||
id="save-entity"
|
id="save-entity"
|
||||||
data-cy="entityCreateSaveButton"
|
data-cy="entityCreateSaveButton"
|
||||||
[disabled]="isSaving"
|
[disabled]="passwordForm.invalid || isSaving"
|
||||||
class="ds-btn ds-btn--primary"
|
class="ds-btn ds-btn--primary"
|
||||||
>
|
>
|
||||||
<span jhiTranslate="entity.action.save">Save</span>
|
<span jhiTranslate="entity.action.save">Save</span>
|
||||||
|
|
|
@ -26,6 +26,7 @@ export class SettingsComponent implements OnInit {
|
||||||
isSaving = false;
|
isSaving = false;
|
||||||
success = false;
|
success = false;
|
||||||
successPassword = false;
|
successPassword = false;
|
||||||
|
samePassword = false;
|
||||||
error = false;
|
error = false;
|
||||||
errorPassword = false;
|
errorPassword = false;
|
||||||
doNotMatch = false;
|
doNotMatch = false;
|
||||||
|
@ -143,16 +144,27 @@ export class SettingsComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
savePassword(): void {
|
savePassword(): void {
|
||||||
|
this.successPassword = false;
|
||||||
|
this.doNotMatch = false;
|
||||||
|
this.samePassword = false;
|
||||||
|
this.errorPassword = false;
|
||||||
|
|
||||||
const passwordNew = this.passwordForm.get(['passwordNew'])!.value;
|
const passwordNew = this.passwordForm.get(['passwordNew'])!.value;
|
||||||
if (passwordNew !== this.passwordForm.get(['passwordNewConfirm'])!.value) {
|
const passwordOld = this.passwordForm.get(['password'])!.value;
|
||||||
this.doNotMatch = true;
|
if (passwordOld == passwordNew) {
|
||||||
|
this.samePassword = true;
|
||||||
} else {
|
} else {
|
||||||
this.passwordService.save(this.passwordForm.get(['passwordNew'])!.value, this.passwordForm.get(['password'])!.value).subscribe(
|
if (passwordNew !== this.passwordForm.get(['passwordNewConfirm'])!.value) {
|
||||||
|
(this.doNotMatch = true), (this.samePassword = false);
|
||||||
|
} else {
|
||||||
|
this.passwordService.save(passwordNew, passwordOld).subscribe(
|
||||||
() => (this.successPassword = true),
|
() => (this.successPassword = true),
|
||||||
|
|
||||||
() => (this.errorPassword = true)
|
() => (this.errorPassword = true)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
trackUserById(index: number, item: IUser): number {
|
trackUserById(index: number, item: IUser): number {
|
||||||
return item.id!;
|
return item.id!;
|
||||||
|
@ -175,15 +187,16 @@ export class SettingsComponent implements OnInit {
|
||||||
|
|
||||||
protected subscribeToSaveResponse(result: Observable<HttpResponse<IUsuarioExtra>>): void {
|
protected subscribeToSaveResponse(result: Observable<HttpResponse<IUsuarioExtra>>): void {
|
||||||
result.pipe(finalize(() => this.onSaveFinalize())).subscribe(
|
result.pipe(finalize(() => this.onSaveFinalize())).subscribe(
|
||||||
() => (
|
() => ((this.success = true), this.windowReload()),
|
||||||
(this.success = true),
|
|
||||||
this.router.navigate(['account/settings']).then(() => {
|
|
||||||
window.location.reload();
|
|
||||||
})
|
|
||||||
),
|
|
||||||
response => this.processError(response)
|
response => this.processError(response)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
windowReload() {
|
||||||
|
this.router.navigate(['account/settings']).then(() => {
|
||||||
|
window.location.reload();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
processError(response: HttpErrorResponse): void {
|
processError(response: HttpErrorResponse): void {
|
||||||
if (response.status === 400) {
|
if (response.status === 400) {
|
||||||
this.error = true;
|
this.error = true;
|
||||||
|
|
|
@ -68,6 +68,7 @@
|
||||||
"suffix": ", puede intentar con las cuentas predeterminadas:<br/>- Administrador (usuario=\"admin\" y contraseña=\"admin\") <br/>- Usuario (usuario=\"user\" y contraseña=\"user\").",
|
"suffix": ", puede intentar con las cuentas predeterminadas:<br/>- Administrador (usuario=\"admin\" y contraseña=\"admin\") <br/>- Usuario (usuario=\"user\" y contraseña=\"user\").",
|
||||||
"updateForm": "Ocurrió un error al actualizar su información, favor revisar los campos e intentar de nuevo",
|
"updateForm": "Ocurrió un error al actualizar su información, favor revisar los campos e intentar de nuevo",
|
||||||
"passwordForm": "Ocurrió un error al actualizar su contraseña, favor revisar los campos e intentar de nuevo",
|
"passwordForm": "Ocurrió un error al actualizar su contraseña, favor revisar los campos e intentar de nuevo",
|
||||||
|
|
||||||
"botonInicio": "Iniciar Sesión"
|
"botonInicio": "Iniciar Sesión"
|
||||||
},
|
},
|
||||||
"register": {
|
"register": {
|
||||||
|
@ -76,7 +77,8 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
"dontmatch": "¡La contraseña y la confirmación de contraseña no coinciden!"
|
"samePassword": "La contraseña actual y la nueva contraseña no pueden ser iguales",
|
||||||
|
"dontmatch": "La contraseña y la confirmación de contraseña no coinciden"
|
||||||
},
|
},
|
||||||
"validate": {
|
"validate": {
|
||||||
"newpassword": {
|
"newpassword": {
|
||||||
|
|
Loading…
Reference in New Issue