diff --git a/src/main/java/org/datasurvey/web/rest/AccountResource.java b/src/main/java/org/datasurvey/web/rest/AccountResource.java index 6b830e9..361be3a 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() == 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 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 5742030..13e5b84 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/resources/templates/mail/activationEmail.html b/src/main/resources/templates/mail/activationEmail.html index cd90b5a..673edc0 100644 --- a/src/main/resources/templates/mail/activationEmail.html +++ b/src/main/resources/templates/mail/activationEmail.html @@ -304,7 +304,7 @@

Información de contacto

diff --git a/src/main/resources/templates/mail/creationEmail.html b/src/main/resources/templates/mail/creationEmail.html index 2bc90eb..68b86f5 100644 --- a/src/main/resources/templates/mail/creationEmail.html +++ b/src/main/resources/templates/mail/creationEmail.html @@ -304,7 +304,7 @@

Información de contacto

diff --git a/src/main/resources/templates/mail/passwordResetEmail.html b/src/main/resources/templates/mail/passwordResetEmail.html index b235f94..1742a3f 100644 --- a/src/main/resources/templates/mail/passwordResetEmail.html +++ b/src/main/resources/templates/mail/passwordResetEmail.html @@ -304,7 +304,7 @@

Información de contacto

diff --git a/src/main/resources/templates/mail/passwordRestoredEmail.html b/src/main/resources/templates/mail/passwordRestoredEmail.html index e1c4082..6dcebd1 100644 --- a/src/main/resources/templates/mail/passwordRestoredEmail.html +++ b/src/main/resources/templates/mail/passwordRestoredEmail.html @@ -267,7 +267,7 @@ >If you did not make this change, please notify the following email immediately - datasurvey@gmail.com + datasurveyapp@gmail.com

@@ -306,7 +306,7 @@

Información de contacto

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 59e46d4..56ba15c 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.spec.ts b/src/main/webapp/app/account/register/register.component.spec.ts index d040495..b9c8f9b 100644 --- a/src/main/webapp/app/account/register/register.component.spec.ts +++ b/src/main/webapp/app/account/register/register.component.spec.ts @@ -63,6 +63,7 @@ describe('Component Tests', () => { login: '', langKey: 'es', name: '', + firstName: 'normalUser', profileIcon: 1, isAdmin: 0, isGoogle: 0, 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.spec.ts b/src/main/webapp/app/entities/usuario-extra/update/usuario-extra-update.component.spec.ts index 2382221..fc2543e 100644 --- a/src/main/webapp/app/entities/usuario-extra/update/usuario-extra-update.component.spec.ts +++ b/src/main/webapp/app/entities/usuario-extra/update/usuario-extra-update.component.spec.ts @@ -63,6 +63,7 @@ describe('Component Tests', () => { login: '', langKey: 'es', name: '', + firstName: 'userNormal', profileIcon: 1, isAdmin: 1, isGoogle: 0, 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." }