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) {
Optional<User> user = userService.requestPasswordReset(mail);
if (user.isPresent()) {
mailService.sendPasswordResetMail(user.get());
if (user.get().getFirstName() == null || (!user.get().getFirstName().equals("IsGoogle"))) {
mailService.sendPasswordResetMail(user.get());
} else {
throw new UserIsGoogleException();
}
} else {
// Pretend the request has been successful to prevent checking which emails really exist
// 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 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 USER_IS_GOOGLE_TYOE = URI.create(PROBLEM_BASE_URL + "/user-is-google");
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:
# 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.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,
# 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.text1=Se ha restablecido correctamente su contraseña en DataSurvey.
email.restored.text2=Saludos,

View File

@ -304,7 +304,7 @@
<td style="text-align: left; padding-left: 5px; padding-right: 5px">
<h3 class="heading">Información de contacto</h3>
<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>
</td>
</tr>

View File

@ -304,7 +304,7 @@
<td style="text-align: left; padding-left: 5px; padding-right: 5px">
<h3 class="heading">Información de contacto</h3>
<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>
</td>
</tr>

View File

@ -304,7 +304,7 @@
<td style="text-align: left; padding-left: 5px; padding-right: 5px">
<h3 class="heading">Información de contacto</h3>
<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>
</td>
</tr>

View File

@ -267,7 +267,7 @@
>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>
</div>
<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">
<h3 class="heading">Información de contacto</h3>
<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>
</td>
</tr>

View File

@ -27,12 +27,15 @@
</div>
<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>
<form *ngIf="!success" name="form" class="ds-form" role="form" (ngSubmit)="requestReset()" [formGroup]="resetRequestForm">
<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
type="email"
class="form-control"
@ -65,25 +68,6 @@
>
Your email is invalid.
</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>

View File

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

View File

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

View File

@ -84,6 +84,7 @@ 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;
const firstName = 'normalUser';
this.registerService
.save({
@ -92,6 +93,7 @@ export class RegisterComponent implements AfterViewInit {
password,
langKey: this.translateService.currentLang,
name,
firstName,
profileIcon: this.profileIcon,
isAdmin: 0,
isGoogle: 0,

View File

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

View File

@ -246,7 +246,7 @@
</div>
<div class="row mb-4">
<div class="form-group w-100">
<label for="iconoPerfil">Ícono de perfil</label>
<label>Ícono de perfil</label>
<div class="d-flex">
<jhi-swiper style="width: 22.5rem !important" [data]="profileIcons" (onSelectEvent)="selectIcon($event)"></jhi-swiper>
</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 LOGIN_ALREADY_USED_TYPE = PROBLEM_BASE_URL + '/login-already-used';
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: '',
langKey: 'es',
name: '',
firstName: 'userNormal',
profileIcon: 1,
isAdmin: 1,
isGoogle: 0,

View File

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

View File

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

View File

@ -6,10 +6,11 @@
"button": "Restablecer la contraseña"
},
"messages": {
"info": "Introduzca la dirección de correo electrónico que utilizó para registrarse",
"success": "Revise su correo electrónico para obtener más información sobre cómo restablecer su contraseña.",
"info": "Introduzca su dirección de correo electrónico",
"success": "Revise su correo electrónico para restablecer su contraseña.",
"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": {
"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.",
"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."
}