validaciones log in

This commit is contained in:
Paola 2021-07-11 15:09:53 -06:00
parent 7fb9b9b88b
commit 453f35b230
5 changed files with 75 additions and 7 deletions

View File

@ -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();
});
}

View File

@ -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 {

View File

@ -71,7 +71,7 @@
<h4 class="text-dark-50 text-center pb-0 fw-bold p-0 m-0" style="color: #727070; font-weight: 700; font-size: 1.3rem">
INICIAR SESION
</h4>
<p class="mb-4" style="color: rgba(146, 146, 146, 0.664)">Ingrese su correo electrónico y contraseña.</p>
<p class="mb-4" style="color: rgba(146, 146, 146, 0.664)">Ingrese su correo electrónico y contraseña</p>
</div>
<div
@ -82,10 +82,11 @@
>
<strong>Failed to sign in!</strong> Please check your credentials and try again.
</div>
<form class="form" role="form" (ngSubmit)="login()" [formGroup]="loginForm">
<div class="mb-3">
<div class="form-group">
<label for="emailaddress" class="form-label">Correo electrónico</label>
<label for="username" class="form-label">Correo electrónico</label>
<input
type="text"
class="form-control"
@ -96,6 +97,41 @@
#username
data-cy="username"
/>
<div
*ngIf="loginForm.get('username')!.invalid && (loginForm.get('username')!.dirty || loginForm.get('username')!.touched)"
>
<small
class="form-text text-danger"
*ngIf="loginForm.get('username')?.errors?.required"
jhiTranslate="global.messages.validate.email.required"
>
Your email is required.
</small>
<small
class="form-text text-danger"
*ngIf="loginForm.get('username')?.errors?.invalid"
jhiTranslate="global.messages.validate.email.invalid"
>
Your email is invalid.
</small>
<small
class="form-text text-danger"
*ngIf="loginForm.get('username')?.errors?.minlength"
jhiTranslate="global.messages.validate.email.minlength"
>
Your email is required to be at least 5 characters.
</small>
<small
class="form-text text-danger"
*ngIf="loginForm.get('username')?.errors?.maxlength"
jhiTranslate="global.messages.validate.email.maxlength"
>
Your email cannot be longer than 100 characters.
</small>
</div>
</div>
</div>
@ -111,6 +147,33 @@
formControlName="password"
data-cy="password"
/>
<div
*ngIf="loginForm.get('password')!.invalid && (loginForm.get('password')!.dirty || loginForm.get('password')!.touched)"
>
<small
class="form-text text-danger"
*ngIf="loginForm.get('password')?.errors?.required"
jhiTranslate="global.messages.validate.newpassword.required"
>
Your password is required.
</small>
<small
class="form-text text-danger"
*ngIf="loginForm.get('password')?.errors?.minlength"
jhiTranslate="global.messages.validate.newpassword.minlength"
>
Your password is required to be at least 4 characters.
</small>
<small
class="form-text text-danger"
*ngIf="loginForm.get('password')?.errors?.maxlength"
jhiTranslate="global.messages.validate.newpassword.maxlength"
>
Your password cannot be longer than 50 characters.
</small>
</div>
</div>
</div>

View File

@ -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(['']);
}

View File

@ -9,7 +9,7 @@
},
"messages": {
"error": {
"authentication": "<strong>¡El inicio de sesión ha fallado!</strong> Por favor, revise las credenciales e intente de nuevo."
"authentication": "Revise las credenciales e intente de nuevo "
}
},
"password": {