arreglo input password perfil

This commit is contained in:
Paola 2021-07-15 15:08:53 -06:00
parent b183dce88a
commit 167ff39036
3 changed files with 43 additions and 27 deletions

View File

@ -190,15 +190,21 @@
(ngSubmit)="save()"
[formGroup]="editForm"
>
<div class="alert alert-danger" *ngIf="error" jhiTranslate="global.messages.info.authenticated.updateForm" data-cy="loginError"></div>
<div *ngIf="success" class="alert alert-success alert-dismissible fade show" role="alert">
Sus datos fueron actualizados de manera exitosa
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="row mb-2">
<div
class="alert alert-danger"
*ngIf="error"
jhiTranslate="global.messages.info.authenticated.updateForm"
data-cy="loginError"
></div>
<div *ngIf="success" class="alert alert-success alert-dismissible fade show" role="alert">
Sus datos fueron actualizados de manera exitosa
<!--<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>-->
</div>
<div class="form-group w-100">
<label class="form-control-label" for="field_email">Correo electrónico</label>
<input type="text" class="form-control" name="email" id="field_email" data-cy="email" formControlName="email" [readonly]="true" />
@ -296,22 +302,29 @@
(ngSubmit)="savePassword()"
[formGroup]="passwordForm"
>
<div *ngIf="success" class="alert alert-success alert-dismissible fade show" role="alert">
Sus contraseña fue actualizada de manera exitosa
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="row mb-3 pb-3" style="border-bottom: 1px solid #e7ebf3">
<div class="alert alert-danger" *ngIf="doNotMatch" jhiTranslate="global.messages.error.dontmatch">
<div
class="alert alert-danger"
*ngIf="errorPassword && !doNotMatch && !successPassword"
jhiTranslate="global.messages.info.authenticated.passwordForm"
data-cy="loginError"
></div>
<div *ngIf="successPassword" class="alert alert-success alert-dismissible fade show" role="alert">
Sus contraseña fue actualizada de manera exitosa
<!-- <button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>-->
</div>
<div class="alert alert-danger" *ngIf="doNotMatch && !successPassword" jhiTranslate="global.messages.error.dontmatch">
The password and its confirmation do not match!
</div>
<div class="form-group w-100">
<label class="form-control-label" for="field_password">Contraseña actual</label>
<input
type="text"
type="password"
class="form-control"
name="password"
id="field_password"
@ -357,7 +370,7 @@
<div class="form-group w-100">
<label class="form-control-label" for="field_passwordNew">Contraseña nueva</label>
<input
type="text"
type="password"
class="form-control"
name="passwordNew"
id="field_passwordNew"
@ -404,7 +417,7 @@
<div class="form-group w-100">
<label class="form-control-label" for="field_passwordNewConfirm">Confirmar contraseña nueva</label>
<input
type="text"
type="password"
class="form-control"
name="passwordNewConfirm"
id="field_passwordNewConfirm"
@ -463,7 +476,7 @@
type="submit"
id="save-entity"
data-cy="entityCreateSaveButton"
[disabled]="passwordForm.invalid || isSaving"
[disabled]="isSaving"
class="ds-btn ds-btn--primary"
>
<span jhiTranslate="entity.action.save">Save</span>

View File

@ -25,7 +25,9 @@ import { PasswordService } from '../password/password.service';
export class SettingsComponent implements OnInit {
isSaving = false;
success = false;
successPassword = false;
error = false;
errorPassword = false;
doNotMatch = false;
usersSharedCollection: IUser[] = [];
plantillasSharedCollection: IPlantilla[] = [];
@ -135,17 +137,17 @@ export class SettingsComponent implements OnInit {
this.subscribeToSaveResponse(this.usuarioExtraService.update(usuarioExtra));
window.location.reload();
//reload
}
savePassword(): void {
const password = this.passwordForm.get(['password'])!.value;
if (password !== this.passwordForm.get(['passwordNew'])!.value) {
const passwordNew = this.passwordForm.get(['passwordNew'])!.value;
if (passwordNew !== this.passwordForm.get(['passwordNewConfirm'])!.value) {
this.doNotMatch = true;
} else {
this.passwordService.save(this.passwordForm.get(['passwordNew'])!.value, password).subscribe(
() => (this.success = true),
() => (this.error = true)
this.passwordService.save(this.passwordForm.get(['passwordNew'])!.value, this.passwordForm.get(['password'])!.value).subscribe(
() => (this.successPassword = true),
() => (this.errorPassword = true)
);
}
}

View File

@ -66,7 +66,8 @@
"prefix": "Si desea ",
"link": "iniciar sesión",
"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"
},
"register": {
"noaccount": "¿Aún no tienes una cuenta?",