From 453f35b230f1a5696ab970265510a747b0889dea Mon Sep 17 00:00:00 2001 From: Paola Date: Sun, 11 Jul 2021 15:09:53 -0600 Subject: [PATCH] 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": {