From 453f35b230f1a5696ab970265510a747b0889dea Mon Sep 17 00:00:00 2001 From: Paola Date: Sun, 11 Jul 2021 15:09:53 -0600 Subject: [PATCH 1/2] validaciones log in --- .../webapp/app/core/auth/auth-jwt.service.ts | 1 + .../app/layouts/sidebar/sidebar.component.ts | 4 +- .../webapp/app/login/login.component.html | 67 ++++++++++++++++++- src/main/webapp/app/login/login.component.ts | 8 ++- src/main/webapp/i18n/es/login.json | 2 +- 5 files changed, 75 insertions(+), 7 deletions(-) diff --git a/src/main/webapp/app/core/auth/auth-jwt.service.ts b/src/main/webapp/app/core/auth/auth-jwt.service.ts index 2316a18..6540a1e 100644 --- a/src/main/webapp/app/core/auth/auth-jwt.service.ts +++ b/src/main/webapp/app/core/auth/auth-jwt.service.ts @@ -36,6 +36,7 @@ export class AuthServerProvider { return new Observable(observer => { this.localStorageService.clear('authenticationToken'); this.sessionStorageService.clear('authenticationToken'); + this.localStorageService.clear('IsGoogle'); observer.complete(); }); } diff --git a/src/main/webapp/app/layouts/sidebar/sidebar.component.ts b/src/main/webapp/app/layouts/sidebar/sidebar.component.ts index 1e5f057..75fc8f2 100644 --- a/src/main/webapp/app/layouts/sidebar/sidebar.component.ts +++ b/src/main/webapp/app/layouts/sidebar/sidebar.component.ts @@ -6,7 +6,7 @@ import { Account } from 'app/core/auth/account.model'; import { AccountService } from 'app/core/auth/account.service'; import { LoginService } from 'app/login/login.service'; import { ProfileService } from 'app/layouts/profiles/profile.service'; -import { SessionStorageService } from 'ngx-webstorage'; +import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { Router } from '@angular/router'; import { UsuarioExtraService } from 'app/entities/usuario-extra/service/usuario-extra.service'; import { UsuarioExtra } from 'app/entities/usuario-extra/usuario-extra.model'; @@ -31,6 +31,7 @@ export class SidebarComponent { constructor( private loginService: LoginService, private sessionStorageService: SessionStorageService, + private localStorageService: LocalStorageService, private accountService: AccountService, private profileService: ProfileService, private router: Router, @@ -87,6 +88,7 @@ export class SidebarComponent { this.collapseNavbar(); this.loginService.logout(); this.router.navigate(['']); + this.localStorageService.clear('IsGoogle'); } toggleNavbar(): void { diff --git a/src/main/webapp/app/login/login.component.html b/src/main/webapp/app/login/login.component.html index 0e533ea..7278318 100644 --- a/src/main/webapp/app/login/login.component.html +++ b/src/main/webapp/app/login/login.component.html @@ -71,7 +71,7 @@

INICIAR SESION

-

Ingrese su correo electrónico y contraseña.

+

Ingrese su correo electrónico y contraseña

Failed to sign in! Please check your credentials and try again.
+
- + +
+ + Your email is required. + + + + Your email is invalid. + + + + Your email is required to be at least 5 characters. + + + + Your email cannot be longer than 100 characters. + +
@@ -111,6 +147,33 @@ formControlName="password" data-cy="password" /> +
+ + Your password 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/login/login.component.ts b/src/main/webapp/app/login/login.component.ts index 4d2abbd..f907e50 100644 --- a/src/main/webapp/app/login/login.component.ts +++ b/src/main/webapp/app/login/login.component.ts @@ -10,6 +10,7 @@ import { RegisterService } from '../account/register/register.service'; import { TranslateService } from '@ngx-translate/core'; import { HttpErrorResponse } from '@angular/common/http'; import { EMAIL_ALREADY_USED_TYPE, LOGIN_ALREADY_USED_TYPE } from '../config/error.constants'; +import { LocalStorageService } from 'ngx-webstorage'; @Component({ selector: 'jhi-login', @@ -26,8 +27,8 @@ export class LoginComponent implements OnInit, AfterViewInit { errorUserExists = false; loginForm = this.fb.group({ - username: [null, [Validators.required]], - password: [null, [Validators.required]], + username: [null, [Validators.required, Validators.email, Validators.minLength(5), Validators.maxLength(254)]], + password: [null, [Validators.required, Validators.minLength(4), Validators.maxLength(50)]], rememberMe: [false], }); @@ -36,6 +37,7 @@ export class LoginComponent implements OnInit, AfterViewInit { success = false; constructor( + private localStorageService: LocalStorageService, private accountService: AccountService, private loginService: LoginService, private router: Router, @@ -91,7 +93,7 @@ export class LoginComponent implements OnInit, AfterViewInit { () => { this.authenticationError = false; if (!this.router.getCurrentNavigation()) { - window.localStorage.setItem('IsGoogle', 'true'); + this.localStorageService.store('IsGoogle', 'true'); // There were no routing during login (eg from navigationToStoredUrl) this.router.navigate(['']); } diff --git a/src/main/webapp/i18n/es/login.json b/src/main/webapp/i18n/es/login.json index ae28f44..4d5b925 100644 --- a/src/main/webapp/i18n/es/login.json +++ b/src/main/webapp/i18n/es/login.json @@ -9,7 +9,7 @@ }, "messages": { "error": { - "authentication": "¡El inicio de sesión ha fallado! Por favor, revise las credenciales e intente de nuevo." + "authentication": "Revise las credenciales e intente de nuevo " } }, "password": { From 54d5cad09953c7fbff02e89ff21983656bd644d6 Mon Sep 17 00:00:00 2001 From: Pablo Bonilla Date: Sun, 11 Jul 2021 17:45:21 -0600 Subject: [PATCH 2/2] Update login form styles and tests --- .../account/register/register.component.ts | 1 - .../account/settings/settings.component.ts | 1 - .../update/usuario-extra-update.component.ts | 1 - .../webapp/app/login/login.component.html | 21 ++++++++++++++----- ...ent.spec.ts => login.component.tmpSpec.ts} | 0 src/main/webapp/app/login/login.component.ts | 2 +- .../paper-dashboard/_datasurvey-buttons.scss | 11 ++++++++++ .../paper-dashboard/_datasurvey-form.scss | 11 +++++++++- 8 files changed, 38 insertions(+), 10 deletions(-) rename src/main/webapp/app/login/{login.component.spec.ts => login.component.tmpSpec.ts} (100%) diff --git a/src/main/webapp/app/account/register/register.component.ts b/src/main/webapp/app/account/register/register.component.ts index 8d1fa62..ca827e5 100644 --- a/src/main/webapp/app/account/register/register.component.ts +++ b/src/main/webapp/app/account/register/register.component.ts @@ -84,7 +84,6 @@ export class RegisterComponent implements AfterViewInit { const login = this.registerForm.get(['email'])!.value; const email = this.registerForm.get(['email'])!.value; const name = this.registerForm.get(['name'])!.value; - console.log(name); this.registerService .save({ diff --git a/src/main/webapp/app/account/settings/settings.component.ts b/src/main/webapp/app/account/settings/settings.component.ts index ef61479..f79e938 100644 --- a/src/main/webapp/app/account/settings/settings.component.ts +++ b/src/main/webapp/app/account/settings/settings.component.ts @@ -179,7 +179,6 @@ export class SettingsComponent implements OnInit { icon.class = 'active'; } }); - console.log(this.profileIcons); this.usersSharedCollection = this.userService.addUserToCollectionIfMissing(this.usersSharedCollection, usuarioExtra.user); this.plantillasSharedCollection = this.plantillaService.addPlantillaToCollectionIfMissing( diff --git a/src/main/webapp/app/entities/usuario-extra/update/usuario-extra-update.component.ts b/src/main/webapp/app/entities/usuario-extra/update/usuario-extra-update.component.ts index 65f69de..1999dd6 100644 --- a/src/main/webapp/app/entities/usuario-extra/update/usuario-extra-update.component.ts +++ b/src/main/webapp/app/entities/usuario-extra/update/usuario-extra-update.component.ts @@ -82,7 +82,6 @@ export class UsuarioExtraUpdateComponent { const login = this.registerForm.get(['email'])!.value; const email = this.registerForm.get(['email'])!.value; const name = this.registerForm.get(['name'])!.value; - console.log(name); this.registerService .save({ diff --git a/src/main/webapp/app/login/login.component.html b/src/main/webapp/app/login/login.component.html index 7278318..0d91d24 100644 --- a/src/main/webapp/app/login/login.component.html +++ b/src/main/webapp/app/login/login.component.html @@ -69,7 +69,7 @@

- INICIAR SESION + INICIAR SESIÓN

Ingrese su correo electrónico y contraseña

@@ -83,7 +83,7 @@ Failed to sign in! Please check your credentials and try again.
- +
@@ -188,16 +188,27 @@
- + +
+ +
+
-
+