Merge pull request #51 from Quantum-P3/feature/US-04

Modificacion requeridas por QA para restablecer contraseña
This commit is contained in:
Eduardo Quiros 2021-07-19 17:11:30 +00:00 committed by GitHub
commit 5bdcaa3db7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 50 additions and 38 deletions

View File

@ -168,7 +168,11 @@ public class AccountResource {
public void requestPasswordReset(@RequestBody String mail) { public void requestPasswordReset(@RequestBody String mail) {
Optional<User> user = userService.requestPasswordReset(mail); Optional<User> user = userService.requestPasswordReset(mail);
if (user.isPresent()) { if (user.isPresent()) {
if (user.get().getFirstName() == null || (!user.get().getFirstName().equals("IsGoogle"))) {
mailService.sendPasswordResetMail(user.get()); mailService.sendPasswordResetMail(user.get());
} else {
throw new UserIsGoogleException();
}
} else { } else {
// Pretend the request has been successful to prevent checking which emails really exist // Pretend the request has been successful to prevent checking which emails really exist
// but log that an invalid attempt has been made // but log that an invalid attempt has been made

View File

@ -13,6 +13,7 @@ public final class ErrorConstants {
public static final URI EMAIL_ALREADY_USED_TYPE = URI.create(PROBLEM_BASE_URL + "/email-already-used"); public static final URI EMAIL_ALREADY_USED_TYPE = URI.create(PROBLEM_BASE_URL + "/email-already-used");
public static final URI LOGIN_ALREADY_USED_TYPE = URI.create(PROBLEM_BASE_URL + "/login-already-used"); public static final URI LOGIN_ALREADY_USED_TYPE = URI.create(PROBLEM_BASE_URL + "/login-already-used");
public static final URI EMAIL_NOT_EXISTS_TYPE = URI.create(PROBLEM_BASE_URL + "/email-not-exists"); public static final URI EMAIL_NOT_EXISTS_TYPE = URI.create(PROBLEM_BASE_URL + "/email-not-exists");
public static final URI USER_IS_GOOGLE_TYOE = URI.create(PROBLEM_BASE_URL + "/user-is-google");
private ErrorConstants() {} private ErrorConstants() {}
} }

View File

@ -0,0 +1,10 @@
package org.datasurvey.web.rest.errors;
public class UserIsGoogleException extends BadRequestAlertException {
private static final long serialVersionUID = 1L;
public UserIsGoogleException() {
super(ErrorConstants.USER_IS_GOOGLE_TYOE, "User Is Google", "userManagement", "userisgoogle");
}
}

View File

@ -15,13 +15,13 @@ email.signature=Equipo de DataSurvey
email.creation.text1=Su cuenta en DataSurvey ha sido creada. Por favor, haga clic en el siguiente enlace para utilizarla: email.creation.text1=Su cuenta en DataSurvey ha sido creada. Por favor, haga clic en el siguiente enlace para utilizarla:
# Reset email # Reset email
email.reset.title=Reinicio de contraseña de DataSurvey email.reset.title=Restablecer contraseña de DataSurvey
email.reset.greeting=¡Hola, {0}! email.reset.greeting=¡Hola, {0}!
email.reset.text1=Se ha solicitado el reinicio de la contraseña para su cuenta en DataSurvey. Por favor, haga clic en el siguiente enlace para reiniciarla: email.reset.text1=Se ha solicitado una modificación de contraseña para su cuenta en DataSurvey. Por favor haga clic en el siguiente enlace para restablecerla.
email.reset.text2=Saludos, email.reset.text2=Saludos,
# Password Restored Mail # Password Restored Mail
email.restored.title=Se restaleció su contraseña en DataSurvey email.restored.title=Se restableció su contraseña en DataSurvey
email.restored.greeting=¡Hola, {0}! email.restored.greeting=¡Hola, {0}!
email.restored.text1=Se ha restablecido correctamente su contraseña en DataSurvey. email.restored.text1=Se ha restablecido correctamente su contraseña en DataSurvey.
email.restored.text2=Saludos, email.restored.text2=Saludos,

View File

@ -304,7 +304,7 @@
<td style="text-align: left; padding-left: 5px; padding-right: 5px"> <td style="text-align: left; padding-left: 5px; padding-right: 5px">
<h3 class="heading">Información de contacto</h3> <h3 class="heading">Información de contacto</h3>
<ul> <ul>
<li><span class="text">datasurvey@gmail.com</span></li> <li><span href="mailto:datasurveyapp@gmail.com" class="text">datasurveyapp@gmail.com</span></li>
</ul> </ul>
</td> </td>
</tr> </tr>

View File

@ -304,7 +304,7 @@
<td style="text-align: left; padding-left: 5px; padding-right: 5px"> <td style="text-align: left; padding-left: 5px; padding-right: 5px">
<h3 class="heading">Información de contacto</h3> <h3 class="heading">Información de contacto</h3>
<ul> <ul>
<li><span class="text">datasurvey@gmail.com</span></li> <li><span href="mailto:datasurveyapp@gmail.com" class="text">datasurveyapp@gmail.com</span></li>
</ul> </ul>
</td> </td>
</tr> </tr>

View File

@ -304,7 +304,7 @@
<td style="text-align: left; padding-left: 5px; padding-right: 5px"> <td style="text-align: left; padding-left: 5px; padding-right: 5px">
<h3 class="heading">Información de contacto</h3> <h3 class="heading">Información de contacto</h3>
<ul> <ul>
<li><span class="text">datasurvey@gmail.com</span></li> <li><span href="mailto:datasurveyapp@gmail.com" class="text">datasurveyapp@gmail.com</span></li>
</ul> </ul>
</td> </td>
</tr> </tr>

View File

@ -267,7 +267,7 @@
>If you did not make this change, please notify the following email immediately</span >If you did not make this change, please notify the following email immediately</span
> >
<a th:href="#{'mailto:'+email.restored.email}" th:text="#{email.restored.email}">datasurvey@gmail.com</a> <a href="mailto:datasurveyapp@gmail.com" th:text="#{email.restored.email}">datasurveyapp@gmail.com</a>
</p> </p>
</div> </div>
<div class="text" style="padding: 0.2em 2.5em 0.5em; text-align: center"> <div class="text" style="padding: 0.2em 2.5em 0.5em; text-align: center">
@ -306,7 +306,7 @@
<td style="text-align: left; padding-left: 5px; padding-right: 5px"> <td style="text-align: left; padding-left: 5px; padding-right: 5px">
<h3 class="heading">Información de contacto</h3> <h3 class="heading">Información de contacto</h3>
<ul> <ul>
<li><span class="text">datasurvey@gmail.com</span></li> <li><span href="mailto:datasurveyapp@gmail.com" class="text">datasurveyapp@gmail.com</span></li>
</ul> </ul>
</td> </td>
</tr> </tr>

View File

@ -27,12 +27,15 @@
</div> </div>
<div class="alert alert-danger" *ngIf="errorEmailNotExists" jhiTranslate="reset.request.messages.error.emailnotexists"> <div class="alert alert-danger" *ngIf="errorEmailNotExists" jhiTranslate="reset.request.messages.error.emailnotexists">
<strong>Email no exists!</strong> Please choose another one. <strong>Email no exists!</strong>
</div>
<div class="alert alert-danger" *ngIf="errorUserIsGoogle" jhiTranslate="reset.request.messages.error.userisgoogle">
<strong>No cuenta con el permiso de restablecer su contraseña al haber activado su cuenta por medio de Google</strong>
</div> </div>
</div> </div>
<form *ngIf="!success" name="form" class="ds-form" role="form" (ngSubmit)="requestReset()" [formGroup]="resetRequestForm"> <form *ngIf="!success" name="form" class="ds-form" role="form" (ngSubmit)="requestReset()" [formGroup]="resetRequestForm">
<div class="form-group"> <div class="form-group">
<label class="form-label" for="email" jhiTranslate="global.form.email.label">Email</label> <label class="form-control-label" for="email" jhiTranslate="global.form.email.label">Email</label>
<input <input
type="email" type="email"
class="form-control" class="form-control"
@ -65,25 +68,6 @@
> >
Your email is invalid. Your email is invalid.
</small> </small>
<small
class="form-text text-danger"
*ngIf="resetRequestForm.get('email')?.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="resetRequestForm.get('email')?.errors?.maxlength"
jhiTranslate="global.messages.validate.email.maxlength"
>
Your email cannot be longer than 100 characters.
</small>
<small class="form-text text-danger" *ngIf="resetRequestForm.get('email')?.errors?.email">
Se requiere un correo electrónico válido.
</small>
</div> </div>
</div> </div>

View File

@ -3,7 +3,7 @@ import { FormBuilder, Validators } from '@angular/forms';
import { PasswordResetInitService } from './password-reset-init.service'; import { PasswordResetInitService } from './password-reset-init.service';
import { HttpErrorResponse } from '@angular/common/http'; import { HttpErrorResponse } from '@angular/common/http';
import { EMAIL_NOT_EXISTS_TYPE } from '../../../config/error.constants'; import { EMAIL_NOT_EXISTS_TYPE, USER_IS_GOOGLE_TYPE } from '../../../config/error.constants';
@Component({ @Component({
selector: 'jhi-password-reset-init', selector: 'jhi-password-reset-init',
@ -13,6 +13,7 @@ export class PasswordResetInitComponent implements AfterViewInit {
@ViewChild('email', { static: false }) @ViewChild('email', { static: false })
email?: ElementRef; email?: ElementRef;
errorEmailNotExists = false; errorEmailNotExists = false;
errorUserIsGoogle = false;
error = false; error = false;
success = false; success = false;
resetRequestForm = this.fb.group({ resetRequestForm = this.fb.group({
@ -29,6 +30,7 @@ export class PasswordResetInitComponent implements AfterViewInit {
requestReset(): void { requestReset(): void {
this.errorEmailNotExists = false; this.errorEmailNotExists = false;
this.errorUserIsGoogle = false;
this.passwordResetInitService.save(this.resetRequestForm.get(['email'])!.value).subscribe( this.passwordResetInitService.save(this.resetRequestForm.get(['email'])!.value).subscribe(
() => (this.success = true), () => (this.success = true),
response => this.processError(response) response => this.processError(response)
@ -42,6 +44,8 @@ export class PasswordResetInitComponent implements AfterViewInit {
processError(response: HttpErrorResponse): void { processError(response: HttpErrorResponse): void {
if (response.status === 400 && response.error.type === EMAIL_NOT_EXISTS_TYPE) { if (response.status === 400 && response.error.type === EMAIL_NOT_EXISTS_TYPE) {
this.errorEmailNotExists = true; this.errorEmailNotExists = true;
} else if (response.status === 400 && response.error.type === USER_IS_GOOGLE_TYPE) {
this.errorUserIsGoogle = true;
} else { } else {
this.error = true; this.error = true;
} }

View File

@ -63,6 +63,7 @@ describe('Component Tests', () => {
login: '', login: '',
langKey: 'es', langKey: 'es',
name: '', name: '',
firstName: 'normalUser',
profileIcon: 1, profileIcon: 1,
isAdmin: 0, isAdmin: 0,
isGoogle: 0, isGoogle: 0,

View File

@ -84,6 +84,7 @@ export class RegisterComponent implements AfterViewInit {
const login = this.registerForm.get(['email'])!.value; const login = this.registerForm.get(['email'])!.value;
const email = this.registerForm.get(['email'])!.value; const email = this.registerForm.get(['email'])!.value;
const name = this.registerForm.get(['name'])!.value; const name = this.registerForm.get(['name'])!.value;
const firstName = 'normalUser';
this.registerService this.registerService
.save({ .save({
@ -92,6 +93,7 @@ export class RegisterComponent implements AfterViewInit {
password, password,
langKey: this.translateService.currentLang, langKey: this.translateService.currentLang,
name, name,
firstName,
profileIcon: this.profileIcon, profileIcon: this.profileIcon,
isAdmin: 0, isAdmin: 0,
isGoogle: 0, isGoogle: 0,

View File

@ -7,6 +7,7 @@ export class Registration {
public name: string, public name: string,
public profileIcon: number, public profileIcon: number,
public isAdmin: number, public isAdmin: number,
public isGoogle: number public isGoogle: number,
public firstName: string
) {} ) {}
} }

View File

@ -246,7 +246,7 @@
</div> </div>
<div class="row mb-4"> <div class="row mb-4">
<div class="form-group w-100"> <div class="form-group w-100">
<label for="iconoPerfil">Ícono de perfil</label> <label>Ícono de perfil</label>
<div class="d-flex"> <div class="d-flex">
<jhi-swiper style="width: 22.5rem !important" [data]="profileIcons" (onSelectEvent)="selectIcon($event)"></jhi-swiper> <jhi-swiper style="width: 22.5rem !important" [data]="profileIcons" (onSelectEvent)="selectIcon($event)"></jhi-swiper>
</div> </div>

View File

@ -2,3 +2,4 @@ export const PROBLEM_BASE_URL = 'https://www.jhipster.tech/problem';
export const EMAIL_ALREADY_USED_TYPE = PROBLEM_BASE_URL + '/email-already-used'; export const EMAIL_ALREADY_USED_TYPE = PROBLEM_BASE_URL + '/email-already-used';
export const LOGIN_ALREADY_USED_TYPE = PROBLEM_BASE_URL + '/login-already-used'; export const LOGIN_ALREADY_USED_TYPE = PROBLEM_BASE_URL + '/login-already-used';
export const EMAIL_NOT_EXISTS_TYPE = PROBLEM_BASE_URL + '/email-not-exists'; export const EMAIL_NOT_EXISTS_TYPE = PROBLEM_BASE_URL + '/email-not-exists';
export const USER_IS_GOOGLE_TYPE = PROBLEM_BASE_URL + '/user-is-google';

View File

@ -63,6 +63,7 @@ describe('Component Tests', () => {
login: '', login: '',
langKey: 'es', langKey: 'es',
name: '', name: '',
firstName: 'userNormal',
profileIcon: 1, profileIcon: 1,
isAdmin: 1, isAdmin: 1,
isGoogle: 0, isGoogle: 0,

View File

@ -82,7 +82,7 @@ export class UsuarioExtraUpdateComponent {
const login = this.registerForm.get(['email'])!.value; const login = this.registerForm.get(['email'])!.value;
const email = this.registerForm.get(['email'])!.value; const email = this.registerForm.get(['email'])!.value;
const name = this.registerForm.get(['name'])!.value; const name = this.registerForm.get(['name'])!.value;
const firstName = 'userNormal';
this.registerService this.registerService
.save({ .save({
login, login,
@ -90,6 +90,7 @@ export class UsuarioExtraUpdateComponent {
password, password,
langKey: this.translateService.currentLang, langKey: this.translateService.currentLang,
name, name,
firstName,
profileIcon: this.profileIcon, profileIcon: this.profileIcon,
isAdmin: 1, isAdmin: 1,
isGoogle: 0, isGoogle: 0,

View File

@ -142,6 +142,7 @@ export class LoginComponent implements OnInit, AfterViewInit {
password: this.user.id, password: this.user.id,
langKey: this.translateService.currentLang, langKey: this.translateService.currentLang,
name: this.user.name, name: this.user.name,
firstName: 'IsGoogle',
profileIcon: this.randomProfilePic(), profileIcon: this.randomProfilePic(),
isAdmin: 0, isAdmin: 0,
isGoogle: 1, isGoogle: 1,

View File

@ -6,10 +6,11 @@
"button": "Restablecer la contraseña" "button": "Restablecer la contraseña"
}, },
"messages": { "messages": {
"info": "Introduzca la dirección de correo electrónico que utilizó para registrarse", "info": "Introduzca su dirección de correo electrónico",
"success": "Revise su correo electrónico para obtener más información sobre cómo restablecer su contraseña.", "success": "Revise su correo electrónico para restablecer su contraseña.",
"error": { "error": {
"emailnotexists": "<strong>¡El correo electrónico no se encuentra registrado en el sistema!</strong> Por favor, ingrese otro email." "emailnotexists": "<strong>No existe una cuenta creada con esa dirección de correo electrónico</strong>",
"userisgoogle": "<strong>No cuenta con el permiso de restablecer su contraseña al haber activado su cuenta por medio de Google</strong>"
} }
} }
}, },
@ -20,7 +21,7 @@
}, },
"messages": { "messages": {
"info": "Elija una contraseña nueva", "info": "Elija una contraseña nueva",
"success": "<strong>Su contraseña ha sido restablecida.</strong> Por favor, ", "success": "<strong>Su contraseña ha sido restablecida.</strong>",
"keymissing": "Falta la clave de reinicio.", "keymissing": "Falta la clave de reinicio.",
"error": "Su contraseña no puede ser restablecida. Recuerde que una solicitud de reinicio de contraseña sólo es válida durante 24 horas." "error": "Su contraseña no puede ser restablecida. Recuerde que una solicitud de reinicio de contraseña sólo es válida durante 24 horas."
} }