From 5d0c87d8d67cc461ad56ecdb060b6d893672c244 Mon Sep 17 00:00:00 2001 From: Mariela Bonilla Date: Sun, 18 Jul 2021 18:02:06 -0600 Subject: [PATCH] =?UTF-8?q?arreglo=20de=20mensajes,=20validaciones=20y=20t?= =?UTF-8?q?extos=20del=20restablecer=20contrase=C3=B1aa?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit arreglos requeridos por calidad de las validaciones: textos de las alertas, textos de subtitulos y verificar que un usuario que se logueó por Google no pueda restablecer la contraseña --- .../datasurvey/web/rest/AccountResource.java | 6 ++++- .../web/rest/errors/ErrorConstants.java | 1 + .../rest/errors/UserIsGoogleException.java | 10 +++++++ .../resources/i18n/messages_es.properties | 6 ++--- .../init/password-reset-init.component.html | 26 ++++--------------- .../init/password-reset-init.component.ts | 6 ++++- .../account/register/register.component.ts | 2 ++ .../app/account/register/register.model.ts | 3 ++- .../account/settings/settings.component.html | 2 +- src/main/webapp/app/config/error.constants.ts | 1 + .../update/usuario-extra-update.component.ts | 3 ++- src/main/webapp/app/login/login.component.ts | 1 + src/main/webapp/i18n/es/reset.json | 9 ++++--- 13 files changed, 43 insertions(+), 33 deletions(-) create mode 100644 src/main/java/org/datasurvey/web/rest/errors/UserIsGoogleException.java diff --git a/src/main/java/org/datasurvey/web/rest/AccountResource.java b/src/main/java/org/datasurvey/web/rest/AccountResource.java index 6b830e9..e175751 100644 --- a/src/main/java/org/datasurvey/web/rest/AccountResource.java +++ b/src/main/java/org/datasurvey/web/rest/AccountResource.java @@ -168,7 +168,11 @@ public class AccountResource { public void requestPasswordReset(@RequestBody String mail) { Optional user = userService.requestPasswordReset(mail); if (user.isPresent()) { - mailService.sendPasswordResetMail(user.get()); + if (!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 diff --git a/src/main/java/org/datasurvey/web/rest/errors/ErrorConstants.java b/src/main/java/org/datasurvey/web/rest/errors/ErrorConstants.java index 109466d..6ae058c 100644 --- a/src/main/java/org/datasurvey/web/rest/errors/ErrorConstants.java +++ b/src/main/java/org/datasurvey/web/rest/errors/ErrorConstants.java @@ -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() {} } diff --git a/src/main/java/org/datasurvey/web/rest/errors/UserIsGoogleException.java b/src/main/java/org/datasurvey/web/rest/errors/UserIsGoogleException.java new file mode 100644 index 0000000..3ab193b --- /dev/null +++ b/src/main/java/org/datasurvey/web/rest/errors/UserIsGoogleException.java @@ -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"); + } +} diff --git a/src/main/resources/i18n/messages_es.properties b/src/main/resources/i18n/messages_es.properties index 32233bb..4be46d2 100644 --- a/src/main/resources/i18n/messages_es.properties +++ b/src/main/resources/i18n/messages_es.properties @@ -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, diff --git a/src/main/webapp/app/account/password-reset/init/password-reset-init.component.html b/src/main/webapp/app/account/password-reset/init/password-reset-init.component.html index d996676..4c988d0 100644 --- a/src/main/webapp/app/account/password-reset/init/password-reset-init.component.html +++ b/src/main/webapp/app/account/password-reset/init/password-reset-init.component.html @@ -27,12 +27,15 @@
- Email no exists! Please choose another one. + Email no exists! +
+
+ No cuenta con el permiso de restablecer su contraseña al haber activado su cuenta por medio de Google
- + Your email is invalid. - - - Your email is required to be at least 5 characters. - - - - Your email cannot be longer than 100 characters. - - - Se requiere un correo electrónico válido. -
diff --git a/src/main/webapp/app/account/password-reset/init/password-reset-init.component.ts b/src/main/webapp/app/account/password-reset/init/password-reset-init.component.ts index 2d63177..09768a8 100644 --- a/src/main/webapp/app/account/password-reset/init/password-reset-init.component.ts +++ b/src/main/webapp/app/account/password-reset/init/password-reset-init.component.ts @@ -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; } diff --git a/src/main/webapp/app/account/register/register.component.ts b/src/main/webapp/app/account/register/register.component.ts index ddcc966..a1727ff 100644 --- a/src/main/webapp/app/account/register/register.component.ts +++ b/src/main/webapp/app/account/register/register.component.ts @@ -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, diff --git a/src/main/webapp/app/account/register/register.model.ts b/src/main/webapp/app/account/register/register.model.ts index 18a4688..ff15f58 100644 --- a/src/main/webapp/app/account/register/register.model.ts +++ b/src/main/webapp/app/account/register/register.model.ts @@ -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 ) {} } diff --git a/src/main/webapp/app/account/settings/settings.component.html b/src/main/webapp/app/account/settings/settings.component.html index 37694de..738b1c0 100644 --- a/src/main/webapp/app/account/settings/settings.component.html +++ b/src/main/webapp/app/account/settings/settings.component.html @@ -246,7 +246,7 @@
- +
diff --git a/src/main/webapp/app/config/error.constants.ts b/src/main/webapp/app/config/error.constants.ts index dc85cc6..ea24e19 100644 --- a/src/main/webapp/app/config/error.constants.ts +++ b/src/main/webapp/app/config/error.constants.ts @@ -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'; diff --git a/src/main/webapp/app/entities/usuario-extra/update/usuario-extra-update.component.ts b/src/main/webapp/app/entities/usuario-extra/update/usuario-extra-update.component.ts index aba080d..4f61529 100644 --- a/src/main/webapp/app/entities/usuario-extra/update/usuario-extra-update.component.ts +++ b/src/main/webapp/app/entities/usuario-extra/update/usuario-extra-update.component.ts @@ -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, diff --git a/src/main/webapp/app/login/login.component.ts b/src/main/webapp/app/login/login.component.ts index 1ae75e2..b0a4685 100644 --- a/src/main/webapp/app/login/login.component.ts +++ b/src/main/webapp/app/login/login.component.ts @@ -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, diff --git a/src/main/webapp/i18n/es/reset.json b/src/main/webapp/i18n/es/reset.json index 2614281..ed3516f 100644 --- a/src/main/webapp/i18n/es/reset.json +++ b/src/main/webapp/i18n/es/reset.json @@ -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": "¡El correo electrónico no se encuentra registrado en el sistema! Por favor, ingrese otro email." + "emailnotexists": "No existe una cuenta creada con esa dirección de correo electrónico", + "userisgoogle": "No cuenta con el permiso de restablecer su contraseña al haber activado su cuenta por medio de Google" } } }, @@ -20,7 +21,7 @@ }, "messages": { "info": "Elija una contraseña nueva", - "success": "Su contraseña ha sido restablecida. Por favor, ", + "success": "Su contraseña ha sido restablecida.", "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." }