From 07e9d80c5766ab11018731eb1bc919385cc5dad6 Mon Sep 17 00:00:00 2001 From: Paola Date: Tue, 13 Jul 2021 15:02:00 -0600 Subject: [PATCH 1/8] Validacion Google para modificar perfil --- .../account/settings/settings.component.html | 19 +++++++++++++++---- .../account/settings/settings.component.ts | 11 ++++++++++- src/main/webapp/i18n/es/login.json | 3 ++- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/main/webapp/app/account/settings/settings.component.html b/src/main/webapp/app/account/settings/settings.component.html index 68d5f1a..3e364b9 100644 --- a/src/main/webapp/app/account/settings/settings.component.html +++ b/src/main/webapp/app/account/settings/settings.component.html @@ -163,7 +163,7 @@ - + ------------------------------------------------------------------------------- --> @@ -273,6 +273,8 @@ Utilice una contraseña segura al realizar el cambio, este dato debe ser secreto ya que provee acceso a su cuenta.

+ +
@@ -297,9 +299,14 @@ data-cy="password" formControlName="password" placeholder="Su contraseña actual" + [readOnly]="isGoogle" />
{ // }); @@ -160,6 +168,7 @@ export class SettingsComponent implements OnInit { this.isSaving = false; } + //Llena el formulario para que se vea en pantalla protected updateForm(usuarioExtra: IUsuarioExtra): void { this.editForm.patchValue({ email: usuarioExtra.user?.login, diff --git a/src/main/webapp/i18n/es/login.json b/src/main/webapp/i18n/es/login.json index 4d5b925..9266406 100644 --- a/src/main/webapp/i18n/es/login.json +++ b/src/main/webapp/i18n/es/login.json @@ -9,7 +9,8 @@ }, "messages": { "error": { - "authentication": "Revise las credenciales e intente de nuevo " + "authentication": "Revise las credenciales e intente de nuevo ", + "isGoogle": "Al haber ingresado por medio de Google no cuenta con los permisos para modificar su contraseña" } }, "password": { From 48a894c455db28cd9b792c5be064c56d422dfc38 Mon Sep 17 00:00:00 2001 From: Paola Date: Tue, 13 Jul 2021 20:27:28 -0600 Subject: [PATCH 2/8] Alertas modificacion usuario --- .../account/settings/settings.component.html | 14 ++++++-- .../account/settings/settings.component.ts | 32 ++++++++++++------- .../usuario-extra/usuario-extra.model.ts | 4 +-- src/main/webapp/i18n/es/global.json | 3 +- 4 files changed, 36 insertions(+), 17 deletions(-) diff --git a/src/main/webapp/app/account/settings/settings.component.html b/src/main/webapp/app/account/settings/settings.component.html index 3e364b9..9cb0e3e 100644 --- a/src/main/webapp/app/account/settings/settings.component.html +++ b/src/main/webapp/app/account/settings/settings.component.html @@ -180,7 +180,7 @@
- +
+
+ +
@@ -221,7 +229,7 @@
- + >): void { result.pipe(finalize(() => this.onSaveFinalize())).subscribe( - () => this.onSaveSuccess(), - () => this.onSaveError() + () => (this.success = true), + response => this.processError(response) ); } + processError(response: HttpErrorResponse): void { + if (response.status === 400) { + this.error = true; + } + } protected onSaveSuccess(): void { this.previousState(); @@ -182,7 +190,7 @@ export class SettingsComponent implements OnInit { }); // Update swiper - this.profileIcon = parseInt(usuarioExtra.iconoPerfil!); + this.profileIcon = usuarioExtra.iconoPerfil!; this.profileIcons.forEach(icon => { if (parseInt(icon.name.split('C')[1]) === this.profileIcon) { icon.class = 'active'; @@ -219,7 +227,7 @@ export class SettingsComponent implements OnInit { ...new UsuarioExtra(), id: this.editForm.get(['id'])!.value, nombre: this.editForm.get(['nombre'])!.value, - iconoPerfil: this.editForm.get(['iconoPerfil'])!.value, + iconoPerfil: this.profileIcon, fechaNacimiento: this.editForm.get(['fechaNacimiento'])!.value ? dayjs(this.editForm.get(['fechaNacimiento'])!.value, DATE_TIME_FORMAT) : undefined, @@ -234,6 +242,8 @@ export class SettingsComponent implements OnInit { document.querySelectorAll('.active').forEach(e => e.classList.remove('active')); event.target.classList.add('active'); this.profileIcon = +event.target.getAttribute('id')! + 1; + + console.log(this.profileIcon); } } } diff --git a/src/main/webapp/app/entities/usuario-extra/usuario-extra.model.ts b/src/main/webapp/app/entities/usuario-extra/usuario-extra.model.ts index 5f4c94f..19bd7f3 100644 --- a/src/main/webapp/app/entities/usuario-extra/usuario-extra.model.ts +++ b/src/main/webapp/app/entities/usuario-extra/usuario-extra.model.ts @@ -8,7 +8,7 @@ import { EstadoUsuario } from 'app/entities/enumerations/estado-usuario.model'; export interface IUsuarioExtra { id?: number; nombre?: string; - iconoPerfil?: string | null; + iconoPerfil?: number | null; fechaNacimiento?: dayjs.Dayjs | null; estado?: EstadoUsuario; user?: IUser | null; @@ -21,7 +21,7 @@ export class UsuarioExtra implements IUsuarioExtra { constructor( public id?: number, public nombre?: string, - public iconoPerfil?: string | null, + public iconoPerfil?: number | null, public fechaNacimiento?: dayjs.Dayjs | null, public estado?: EstadoUsuario, public user?: IUser | null, diff --git a/src/main/webapp/i18n/es/global.json b/src/main/webapp/i18n/es/global.json index 8484710..bc24f01 100644 --- a/src/main/webapp/i18n/es/global.json +++ b/src/main/webapp/i18n/es/global.json @@ -65,7 +65,8 @@ "authenticated": { "prefix": "Si desea ", "link": "iniciar sesión", - "suffix": ", puede intentar con las cuentas predeterminadas:
- Administrador (usuario=\"admin\" y contraseña=\"admin\")
- Usuario (usuario=\"user\" y contraseña=\"user\")." + "suffix": ", puede intentar con las cuentas predeterminadas:
- Administrador (usuario=\"admin\" y contraseña=\"admin\")
- Usuario (usuario=\"user\" y contraseña=\"user\").", + "updateForm": "Ocurrió un error al actualizar su información, favor revisar los campos e intentar de nuevo" }, "register": { "noaccount": "¿Aún no tienes una cuenta?", From ab65108475b4ebfd5ee486dbc999f26ea87c2929 Mon Sep 17 00:00:00 2001 From: Paola Date: Tue, 13 Jul 2021 21:49:46 -0600 Subject: [PATCH 3/8] Validacion fecha para modifcacion perfil --- .../webapp/app/account/settings/settings.component.html | 2 ++ src/main/webapp/app/account/settings/settings.component.ts | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/webapp/app/account/settings/settings.component.html b/src/main/webapp/app/account/settings/settings.component.html index 9cb0e3e..33bfed4 100644 --- a/src/main/webapp/app/account/settings/settings.component.html +++ b/src/main/webapp/app/account/settings/settings.component.html @@ -390,6 +390,7 @@
+
+
+
+ The password and its confirmation do not match! +
+
This field is required. + + + Your password is required to be at least 4 characters. + + + + Your password cannot be longer than 50 characters. +
@@ -353,6 +380,22 @@ > This field is required.
+ + + Your password is required to be at least 4 characters. + + + + Your password cannot be longer than 50 characters. +
@@ -384,6 +427,21 @@ > This field is required. + + Your password is required to be at least 4 characters. + + + + Your password cannot be longer than 50 characters. + diff --git a/src/main/webapp/app/account/settings/settings.component.ts b/src/main/webapp/app/account/settings/settings.component.ts index 0c5b543..82ee0f8 100644 --- a/src/main/webapp/app/account/settings/settings.component.ts +++ b/src/main/webapp/app/account/settings/settings.component.ts @@ -16,6 +16,7 @@ import { UsuarioExtraService } from 'app/entities/usuario-extra/service/usuario- import { AccountService } from 'app/core/auth/account.service'; import { LocalStorageService } from 'ngx-webstorage'; import { EMAIL_ALREADY_USED_TYPE, LOGIN_ALREADY_USED_TYPE } from '../../config/error.constants'; +import { PasswordService } from '../password/password.service'; @Component({ selector: 'jhi-settings', @@ -25,6 +26,7 @@ export class SettingsComponent implements OnInit { isSaving = false; success = false; error = false; + doNotMatch = false; usersSharedCollection: IUser[] = []; plantillasSharedCollection: IPlantilla[] = []; @@ -44,9 +46,9 @@ export class SettingsComponent implements OnInit { //form de la contraseña passwordForm = this.fb.group({ - password: [null, [Validators.required]], - passwordNew: [null, [Validators.required]], - passwordNewConfirm: [null, [Validators.required]], + password: [null, [Validators.required], Validators.minLength(8), Validators.maxLength(50)], + passwordNew: [null, [Validators.required], Validators.minLength(8), Validators.maxLength(50)], + passwordNewConfirm: [null, [Validators.required, Validators.minLength(8), Validators.maxLength(50)]], }); usuarioExtra: UsuarioExtra | null = null; @@ -89,7 +91,8 @@ export class SettingsComponent implements OnInit { protected activatedRoute: ActivatedRoute, protected fb: FormBuilder, protected accountService: AccountService, - private localStorageService: LocalStorageService + private localStorageService: LocalStorageService, + protected passwordService: PasswordService ) {} ngOnInit(): void { @@ -131,6 +134,20 @@ export class SettingsComponent implements OnInit { console.log(usuarioExtra.fechaNacimiento); this.subscribeToSaveResponse(this.usuarioExtraService.update(usuarioExtra)); + + window.location.reload(); + } + + savePassword(): void { + const password = this.passwordForm.get(['password'])!.value; + if (password !== this.passwordForm.get(['passwordNew'])!.value) { + this.doNotMatch = true; + } else { + this.passwordService.save(this.passwordForm.get(['passwordNew'])!.value, password).subscribe( + () => (this.success = true), + () => (this.error = true) + ); + } } trackUserById(index: number, item: IUser): number { @@ -237,8 +254,6 @@ export class SettingsComponent implements OnInit { }; } - protected CreateFormPassword(); - selectIcon(event: MouseEvent): void { if (event.target instanceof Element) { document.querySelectorAll('.active').forEach(e => e.classList.remove('active')); From 167ff39036091380da9263e4986a4b160a7fcdd8 Mon Sep 17 00:00:00 2001 From: Paola Date: Thu, 15 Jul 2021 15:08:53 -0600 Subject: [PATCH 6/8] arreglo input password perfil --- .../account/settings/settings.component.html | 53 ++++++++++++------- .../account/settings/settings.component.ts | 14 ++--- src/main/webapp/i18n/es/global.json | 3 +- 3 files changed, 43 insertions(+), 27 deletions(-) diff --git a/src/main/webapp/app/account/settings/settings.component.html b/src/main/webapp/app/account/settings/settings.component.html index b60c1d9..d12e710 100644 --- a/src/main/webapp/app/account/settings/settings.component.html +++ b/src/main/webapp/app/account/settings/settings.component.html @@ -190,15 +190,21 @@ (ngSubmit)="save()" [formGroup]="editForm" > -
- -
+
+ + +
@@ -296,22 +302,29 @@ (ngSubmit)="savePassword()" [formGroup]="passwordForm" > - -
-
+
+ + + +
The password and its confirmation do not match!
Save diff --git a/src/main/webapp/app/account/settings/settings.component.ts b/src/main/webapp/app/account/settings/settings.component.ts index 82ee0f8..fc97e7c 100644 --- a/src/main/webapp/app/account/settings/settings.component.ts +++ b/src/main/webapp/app/account/settings/settings.component.ts @@ -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) ); } } diff --git a/src/main/webapp/i18n/es/global.json b/src/main/webapp/i18n/es/global.json index bcceeb3..787970d 100644 --- a/src/main/webapp/i18n/es/global.json +++ b/src/main/webapp/i18n/es/global.json @@ -66,7 +66,8 @@ "prefix": "Si desea ", "link": "iniciar sesión", "suffix": ", puede intentar con las cuentas predeterminadas:
- Administrador (usuario=\"admin\" y contraseña=\"admin\")
- 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?", From f349ee6020883372943946b9f36a3c798303f513 Mon Sep 17 00:00:00 2001 From: Paola Date: Thu, 15 Jul 2021 22:07:23 -0600 Subject: [PATCH 7/8] modificacion perfil passwords fix --- .../account/settings/settings.component.html | 1 + .../account/settings/settings.component.ts | 21 ++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/main/webapp/app/account/settings/settings.component.html b/src/main/webapp/app/account/settings/settings.component.html index d12e710..61968bb 100644 --- a/src/main/webapp/app/account/settings/settings.component.html +++ b/src/main/webapp/app/account/settings/settings.component.html @@ -333,6 +333,7 @@ placeholder="Su contraseña actual" [readOnly]="isGoogle" /> +