arreglo validacion log in suspended

This commit is contained in:
Paola 2021-07-23 13:50:18 -06:00
parent 24eaed7fbc
commit 0bd50e331c
7 changed files with 34 additions and 26 deletions

View File

@ -40,6 +40,7 @@ public class UserJWTController {
Authentication authentication = authenticationManagerBuilder.getObject().authenticate(authenticationToken); Authentication authentication = authenticationManagerBuilder.getObject().authenticate(authenticationToken);
SecurityContextHolder.getContext().setAuthentication(authentication); SecurityContextHolder.getContext().setAuthentication(authentication);
String jwt = tokenProvider.createToken(authentication, loginVM.isRememberMe()); String jwt = tokenProvider.createToken(authentication, loginVM.isRememberMe());
HttpHeaders httpHeaders = new HttpHeaders(); HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.add(JWTFilter.AUTHORIZATION_HEADER, "Bearer " + jwt); httpHeaders.add(JWTFilter.AUTHORIZATION_HEADER, "Bearer " + jwt);
return new ResponseEntity<>(new JWTToken(jwt), httpHeaders, HttpStatus.OK); return new ResponseEntity<>(new JWTToken(jwt), httpHeaders, HttpStatus.OK);

View File

@ -1,18 +1,12 @@
<form *ngIf="usuarioExtra" name="deleteForm" (ngSubmit)="confirmDelete(usuarioExtra)"> <form *ngIf="usuarioExtra" name="deleteForm" (ngSubmit)="confirmDelete(usuarioExtra)">
<div class="modal-header"> <div class="modal-header">
<h4 class="modal-title" data-cy="usuarioExtraDeleteDialogHeading" jhiTranslate="entity.delete.status">Confirm delete operation</h4> <!--<h4 class="modal-title" data-cy="usuarioExtraDeleteDialogHeading" jhiTranslate="entity.delete.status">Confirm delete operation</h4>-->
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" (click)="cancel()">&times;</button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<jhi-alert-error></jhi-alert-error> <jhi-alert-error></jhi-alert-error>
<p <p id="jhi-delete-usuarioExtra-heading" jhiTranslate="dataSurveyApp.usuarioExtra.delete.question"></p>
id="jhi-delete-usuarioExtra-heading"
jhiTranslate="dataSurveyApp.usuarioExtra.delete.question"
[translateValues]="{ nombre: usuarioExtra.user.email }"
></p>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
@ -20,8 +14,8 @@
<fa-icon icon="ban"></fa-icon>&nbsp;<span jhiTranslate="entity.action.cancel">Cancel</span> <fa-icon icon="ban"></fa-icon>&nbsp;<span jhiTranslate="entity.action.cancel">Cancel</span>
</button> </button>
<button id="jhi-confirm-delete-usuarioExtra" data-cy="entityConfirmDeleteButton" type="submit" class="btn btn-danger"> <button id="jhi-confirm-delete-usuarioExtra" data-cy="entityConfirmDeleteButton" type="submit" class="btn btn-warning">
<fa-icon icon="times"></fa-icon>&nbsp;<span jhiTranslate="entity.action.toggleStatus">Cambiar estado</span> <span jhiTranslate="entity.action.toggleStatus">Cambiar estado</span>
</button> </button>
</div> </div>
</form> </form>

View File

@ -64,9 +64,8 @@
<span class="d-none d-md-inline" jhiTranslate="entity.action.view">View</span> <span class="d-none d-md-inline" jhiTranslate="entity.action.view">View</span>
</button> </button>
&nbsp;&nbsp; &nbsp;&nbsp;
<button type="submit" (click)="delete(usuarioExtra)" class="ds-btn ds-btn--danger btn-sm" data-cy="entityDeleteButton"> <button type="submit" (click)="delete(usuarioExtra)" class="btn-sm ds-btn ds-btn--toggle" data-cy="entityDeleteButton">
<fa-icon icon="times"></fa-icon> <span class="d-none d-md-inline" jhiTranslate="entity.action.toggleStatus"></span>
<span class="d-none d-md-inline" jhiTranslate="entity.action.delete"></span>
</button> </button>
</div> </div>
</td> </td>

View File

@ -74,12 +74,7 @@
<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>
<div <div class="alert alert-danger" *ngIf="error" jhiTranslate="login.messages.error.authentication" data-cy="loginError">
class="alert alert-danger"
*ngIf="authenticationError"
jhiTranslate="login.messages.error.authentication"
data-cy="loginError"
>
<strong>Failed to sign in!</strong> Please check your credentials and try again. <strong>Failed to sign in!</strong> Please check your credentials and try again.
</div> </div>

View File

@ -11,6 +11,8 @@ import { TranslateService } from '@ngx-translate/core';
import { HttpErrorResponse } from '@angular/common/http'; import { HttpErrorResponse } from '@angular/common/http';
import { EMAIL_ALREADY_USED_TYPE, LOGIN_ALREADY_USED_TYPE, USER_IS_SUSPENDED } from '../config/error.constants'; import { EMAIL_ALREADY_USED_TYPE, LOGIN_ALREADY_USED_TYPE, USER_IS_SUSPENDED } from '../config/error.constants';
import { LocalStorageService } from 'ngx-webstorage'; import { LocalStorageService } from 'ngx-webstorage';
import { UsuarioExtra } from '../entities/usuario-extra/usuario-extra.model';
import { Account } from '../core/auth/account.model';
@Component({ @Component({
selector: 'jhi-login', selector: 'jhi-login',
@ -88,7 +90,14 @@ export class LoginComponent implements OnInit, AfterViewInit {
this.router.navigate(['']); this.router.navigate(['']);
} }
}, },
() => this.activateGoogle() response => {
debugger;
if (response.status == 401 && response.error.detail == 'Bad credentials') {
this.activateGoogle();
} else {
this.processError(response);
}
}
); );
} }
@ -97,11 +106,12 @@ export class LoginComponent implements OnInit, AfterViewInit {
} }
processError(response: HttpErrorResponse): void { processError(response: HttpErrorResponse): void {
debugger;
if (response.status === 400 && response.error.type === LOGIN_ALREADY_USED_TYPE) { if (response.status === 400 && response.error.type === LOGIN_ALREADY_USED_TYPE) {
this.errorUserExists = true; this.errorUserExists = true;
} else if (response.status === 400 && response.error.type === EMAIL_ALREADY_USED_TYPE) { } else if (response.status === 400 && response.error.type === EMAIL_ALREADY_USED_TYPE) {
this.errorEmailExists = true; this.errorEmailExists = true;
} else if (response.status === 401 && response.error.type === USER_IS_SUSPENDED) { } else if (response.status === 401) {
this.userSuspended = true; this.userSuspended = true;
} else { } else {
this.error = true; this.error = true;
@ -136,7 +146,6 @@ export class LoginComponent implements OnInit, AfterViewInit {
login(): void { login(): void {
debugger; debugger;
this.loginService this.loginService
.login({ .login({
username: this.loginForm.get('username')!.value, username: this.loginForm.get('username')!.value,
@ -144,14 +153,24 @@ export class LoginComponent implements OnInit, AfterViewInit {
rememberMe: this.loginForm.get('rememberMe')!.value, rememberMe: this.loginForm.get('rememberMe')!.value,
}) })
.subscribe( .subscribe(
() => { value => {
debugger;
console.log(value);
/*if (value?.activated == false){
this.userSuspended = true;
console.log(value.activated)
}else {*/
this.authenticationError = false; this.authenticationError = false;
if (!this.router.getCurrentNavigation()) { if (!this.router.getCurrentNavigation()) {
// There were no routing during login (eg from navigationToStoredUrl) // There were no routing during login (eg from navigationToStoredUrl)
this.router.navigate(['']); this.router.navigate(['']);
} }
// }
}, },
() => (this.authenticationError = true)
response => this.processError(response)
); );
} }
} }

View File

@ -11,7 +11,7 @@
"error": { "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", "isGoogle": "Al haber ingresado por medio de Google no cuenta con los permisos para modificar su contraseña",
"userSuspended": "No cuenta con los permisos para iniciar sesión, su cuenta se encuentra suspendida" "userSuspended": "No cuenta con los permisos para iniciar sesión. Su cuenta se encuentra suspendida"
} }
}, },
"password": { "password": {

View File

@ -12,7 +12,7 @@
"updated": "El usuario con el identificador {{ param }} ha sido actualizado", "updated": "El usuario con el identificador {{ param }} ha sido actualizado",
"deleted": "El usuario con el identificador {{ param }} ha sido eliminado", "deleted": "El usuario con el identificador {{ param }} ha sido eliminado",
"delete": { "delete": {
"question": "¿Seguro que quiere modificar el estado del usuario '{{ nombre }}' ?" "question": "¿Seguro que quiere modificar el estado del usuario ?"
}, },
"detail": { "detail": {
"title": "Usuario" "title": "Usuario"