Add reestablecer contraseña

se  implementó de mejor manera el reestablecer la contraseña
modificando y agregaron los estilos respectivos a ambas páginas del reestablcer contraseña y revisando que estuvieran los elementos adecuados y la funcionalidad adecuada
This commit is contained in:
Mariela Bonilla 2021-07-16 04:52:02 -06:00
parent 0092d87aae
commit ed51fa3694
9 changed files with 335 additions and 209 deletions

View File

@ -19,3 +19,11 @@ email.reset.title=DataSurvey password reset
email.reset.greeting=Dear {0} email.reset.greeting=Dear {0}
email.reset.text1=For your DataSurvey account a password reset was requested, please click on the URL below to reset it: email.reset.text1=For your DataSurvey account a password reset was requested, please click on the URL below to reset it:
email.reset.text2=Regards, email.reset.text2=Regards,
# Password Restored Mail
email.restored.title=Your password was reset in DataSurvey
email.restored.greeting=Hello, {0}!
email.restored.text1=Your DataSurvey password has been successfully reset..
email.restored.text2=Regards,
email.restored.text3=If you did not make this change, please notify the following email immediately:
email.restored.email=datasurvey@gmail.com

View File

@ -19,3 +19,12 @@ email.reset.title=Reinicio de 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 el reinicio de la contraseña para su cuenta en DataSurvey. Por favor, haga clic en el siguiente enlace para reiniciarla:
email.reset.text2=Saludos, email.reset.text2=Saludos,
# Password Restored Mail
email.restored.title=Se restaleció 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,
email.restored.text3=Si usted no realizó este cambio, favor notifique inmediatamente al siguiente correo:
email.restored.email=datasurvey@gmail.com

View File

@ -1,137 +1,172 @@
<div> <div class="account-pages pt-2 pt-sm-5 pb-4 pb-sm-5" style="height: 100vh; background-color: #f1f5f9">
<div class="row justify-content-center"> <div class="container">
<div class="col-md-4"> <div class="row justify-content-center">
<h1 jhiTranslate="reset.finish.title">Reset password</h1> <div class="col-xxl-4 col-lg-5">
<div class="card mt-5">
<div class="alert alert-danger" jhiTranslate="reset.finish.messages.keymissing" *ngIf="initialized && !key"> <!-- Logo -->
<strong>The password reset key is missing.</strong> <div class="pl-4 pt-4 pr-4 pb-1 text-center">
</div> <img src="../../content/img_datasurvey/datasurvey-logo-text-black.svg" alt="" />
<div class="alert alert-warning" *ngIf="key && !success">
<span jhiTranslate="reset.finish.messages.info">Choose a new password</span>
</div>
<div class="alert alert-danger" *ngIf="error">
<span jhiTranslate="reset.finish.messages.error"
>Your password couldn't be reset. Remember a password request is only valid for 24 hours.</span
>
</div>
<div class="alert alert-success" *ngIf="success">
<span jhiTranslate="reset.finish.messages.success"><strong>Your password has been reset.</strong> Please </span>
<a class="alert-link" routerLink="/login" jhiTranslate="global.messages.info.authenticated.link">sign in</a>.
</div>
<div class="alert alert-danger" *ngIf="doNotMatch" jhiTranslate="global.messages.error.dontmatch">
The password and its confirmation do not match!
</div>
<div *ngIf="key && !success">
<form name="form" role="form" (ngSubmit)="finishReset()" [formGroup]="passwordForm">
<div class="form-group">
<label class="form-control-label" for="newPassword" jhiTranslate="global.form.newpassword.label">New password</label>
<input
type="password"
class="form-control"
id="newPassword"
name="newPassword"
placeholder="{{ 'global.form.newpassword.placeholder' | translate }}"
formControlName="newPassword"
data-cy="resetPassword"
#newPassword
/>
<div
*ngIf="
passwordForm.get('newPassword')!.invalid &&
(passwordForm.get('newPassword')!.dirty || passwordForm.get('newPassword')!.touched)
"
>
<small
class="form-text text-danger"
*ngIf="passwordForm.get('newPassword')?.errors?.required"
jhiTranslate="global.messages.validate.newpassword.required"
>
Your password is required.
</small>
<small
class="form-text text-danger"
*ngIf="passwordForm.get('newPassword')?.errors?.minlength"
jhiTranslate="global.messages.validate.newpassword.minlength"
>
Your password is required to be at least 4 characters.
</small>
<small
class="form-text text-danger"
*ngIf="passwordForm.get('newPassword')?.errors?.maxlength"
jhiTranslate="global.messages.validate.newpassword.maxlength"
>
Your password cannot be longer than 50 characters.
</small>
</div>
<jhi-password-strength-bar [passwordToCheck]="passwordForm.get('newPassword')!.value"></jhi-password-strength-bar>
</div> </div>
<div class="form-group"> <div class="card-body p-4">
<label class="form-control-label" for="confirmPassword" jhiTranslate="global.form.confirmpassword.label" <div class="text-center w-75 m-auto">
>New password confirmation</label <h4
> class="text-dark-50 text-center pb-0 fw-bold p-0 m-0"
<input style="color: #727070; font-weight: 700; font-size: 1.3rem"
type="password" jhiTranslate="reset.finish.title"
class="form-control"
id="confirmPassword"
name="confirmPassword"
placeholder="{{ 'global.form.confirmpassword.placeholder' | translate }}"
formControlName="confirmPassword"
data-cy="confirmResetPassword"
/>
<div
*ngIf="
passwordForm.get('confirmPassword')!.invalid &&
(passwordForm.get('confirmPassword')!.dirty || passwordForm.get('confirmPassword')!.touched)
"
>
<small
class="form-text text-danger"
*ngIf="passwordForm.get('confirmPassword')?.errors?.required"
jhiTranslate="global.messages.validate.confirmpassword.required"
> >
Your password confirmation is required. Reset password
</small> </h4>
<small <p class="mb-4" style="color: rgba(146, 146, 146, 0.664)" *ngIf="key && !success" jhiTranslate="reset.finish.messages.info">
class="form-text text-danger" Choose a new password
*ngIf="passwordForm.get('confirmPassword')?.errors?.minlength" </p>
jhiTranslate="global.messages.validate.confirmpassword.minlength" </div>
> <div>
Your password confirmation is required to be at least 4 characters. <div class="alert alert-danger" jhiTranslate="reset.finish.messages.keymissing" *ngIf="initialized && !key">
</small> <strong>The password reset key is missing.</strong>
</div>
<small <div class="alert alert-danger" *ngIf="error">
class="form-text text-danger" <span jhiTranslate="reset.finish.messages.error"
*ngIf="passwordForm.get('confirmPassword')?.errors?.maxlength" >Your password couldn't be reset. Remember a password request is only valid for 24 hours.</span
jhiTranslate="global.messages.validate.confirmpassword.maxlength" >
> </div>
Your password confirmation cannot be longer than 50 characters. <div *ngIf="success">
</small> <div class="alert alert-success text-center my-2">
<span jhiTranslate="reset.finish.messages.success"><strong>Your password has been reset.</strong></span>
<strong><span jhiTranslate="global.messages.info.authenticated.link">sign in</span></strong>
</div>
<div class="d-flex justify-content-center">
<button class="ds-btn ds-btn--primary" routerLink="/login" jhiTranslate="global.messages.info.authenticated.botonInicio">
sign in</button
>.
</div>
</div>
<div class="alert alert-danger" *ngIf="doNotMatch" jhiTranslate="global.messages.error.dontmatch">
The password and its confirmation do not match!
</div>
</div>
<div *ngIf="key && !success">
<form name="form" class="ds-form" role="form" (ngSubmit)="finishReset()" [formGroup]="passwordForm">
<div class="form-group">
<label class="form-control-label" for="newPassword" jhiTranslate="global.form.newpassword.label">New password</label>
<input
type="password"
class="form-control"
id="newPassword"
name="newPassword"
placeholder="{{ 'global.form.newpassword.placeholder' | translate }}"
formControlName="newPassword"
data-cy="resetPassword"
#newPassword
/>
<div
*ngIf="
passwordForm.get('newPassword')!.invalid &&
(passwordForm.get('newPassword')!.dirty || passwordForm.get('newPassword')!.touched)
"
>
<small
class="form-text text-danger"
*ngIf="passwordForm.get('newPassword')?.errors?.required"
jhiTranslate="global.messages.validate.newpassword.required"
>
Your password is required.
</small>
<small
class="form-text text-danger"
*ngIf="passwordForm.get('newPassword')?.errors?.minlength"
jhiTranslate="global.messages.validate.newpassword.minlength"
>
Your password is required to be at least 8 characters.
</small>
<small
class="form-text text-danger"
*ngIf="passwordForm.get('newPassword')?.errors?.maxlength"
jhiTranslate="global.messages.validate.newpassword.maxlength"
>
Your password cannot be longer than 50 characters.
</small>
</div>
<!--<jhi-password-strength-bar [passwordToCheck]="passwordForm.get('newPassword')!.value"></jhi-password-strength-bar>-->
</div>
<div class="form-group">
<label class="form-control-label" for="confirmPassword" jhiTranslate="global.form.confirmpassword.label"
>New password confirmation</label
>
<input
type="password"
class="form-control"
id="confirmPassword"
name="confirmPassword"
placeholder="{{ 'global.form.confirmpassword.placeholder' | translate }}"
formControlName="confirmPassword"
data-cy="confirmResetPassword"
/>
<div
*ngIf="
passwordForm.get('confirmPassword')!.invalid &&
(passwordForm.get('confirmPassword')!.dirty || passwordForm.get('confirmPassword')!.touched)
"
>
<small
class="form-text text-danger"
*ngIf="passwordForm.get('confirmPassword')?.errors?.required"
jhiTranslate="global.messages.validate.confirmpassword.required"
>
Your password confirmation is required.
</small>
<small
class="form-text text-danger"
*ngIf="passwordForm.get('confirmPassword')?.errors?.minlength"
jhiTranslate="global.messages.validate.confirmpassword.minlength"
>
Your password confirmation is required to be at least 8 characters.
</small>
<small
class="form-text text-danger"
*ngIf="passwordForm.get('confirmPassword')?.errors?.maxlength"
jhiTranslate="global.messages.validate.confirmpassword.maxlength"
>
Your password confirmation cannot be longer than 50 characters.
</small>
</div>
</div>
<div class="row justify-content-center">
<button
type="submit"
[disabled]="passwordForm.invalid"
class="ds-btn ds-btn--primary"
jhiTranslate="reset.finish.form.button"
data-cy="submit"
>
Reset Password
</button>
</div>
</form>
</div> </div>
</div> </div>
<!-- end card-body -->
</div>
<!-- end card -->
<button <!-- end row -->
type="submit"
[disabled]="passwordForm.invalid"
class="btn btn-primary"
jhiTranslate="reset.finish.form.button"
data-cy="submit"
>
Reset Password
</button>
</form>
</div> </div>
<!-- end col -->
</div> </div>
<!-- end row -->
</div> </div>
<!-- end container -->
</div> </div>
<!-- end page -->

View File

@ -19,8 +19,8 @@ export class PasswordResetFinishComponent implements OnInit, AfterViewInit {
key = ''; key = '';
passwordForm = this.fb.group({ passwordForm = this.fb.group({
newPassword: ['', [Validators.required, Validators.minLength(4), Validators.maxLength(50)]], newPassword: ['', [Validators.required, Validators.minLength(8), Validators.maxLength(50)]],
confirmPassword: ['', [Validators.required, Validators.minLength(4), Validators.maxLength(50)]], confirmPassword: ['', [Validators.required, Validators.minLength(8), Validators.maxLength(50)]],
}); });
constructor(private passwordResetFinishService: PasswordResetFinishService, private route: ActivatedRoute, private fb: FormBuilder) {} constructor(private passwordResetFinishService: PasswordResetFinishService, private route: ActivatedRoute, private fb: FormBuilder) {}

View File

@ -1,81 +1,132 @@
<div> <div class="account-pages pt-2 pt-sm-5 pb-4 pb-sm-5" style="height: 100vh; background-color: #f1f5f9">
<div class="row justify-content-center"> <div class="container">
<div class="col-md-8"> <div class="row justify-content-center">
<h1 jhiTranslate="reset.request.title">Reset your password</h1> <div class="col-xxl-4 col-lg-5">
<div class="card mt-5">
<jhi-alert-error></jhi-alert-error> <!-- Logo -->
<div class="pl-4 pt-4 pr-4 pb-1 text-center">
<div class="alert alert-warning" *ngIf="!success"> <img src="../../content/img_datasurvey/datasurvey-logo-text-black.svg" alt="" />
<span jhiTranslate="reset.request.messages.info">Enter the email address you used to register.</span>
</div>
<div class="alert alert-success" *ngIf="success">
<span jhiTranslate="reset.request.messages.success">Check your emails for details on how to reset your password.</span>
</div>
<form *ngIf="!success" name="form" role="form" (ngSubmit)="requestReset()" [formGroup]="resetRequestForm">
<div class="form-group">
<label class="form-control-label" for="email" jhiTranslate="global.form.email.label">Email</label>
<input
type="email"
class="form-control"
id="email"
name="email"
placeholder="{{ 'global.form.email.placeholder' | translate }}"
formControlName="email"
data-cy="emailResetPassword"
#email
/>
<div
*ngIf="
resetRequestForm.get('email')!.invalid && (resetRequestForm.get('email')!.dirty || resetRequestForm.get('email')!.touched)
"
>
<small
class="form-text text-danger"
*ngIf="resetRequestForm.get('email')?.errors?.required"
jhiTranslate="global.messages.validate.email.required"
>
Your email is required.
</small>
<small
class="form-text text-danger"
*ngIf="resetRequestForm.get('email')?.errors?.email"
jhiTranslate="global.messages.validate.email.invalid"
>
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>
</div> </div>
</div>
<button <div class="card-body p-4">
type="submit" <div class="text-center w-75 m-auto">
[disabled]="resetRequestForm.invalid" <h4
class="btn btn-primary" class="text-dark-50 text-center pb-0 fw-bold p-0 m-0"
jhiTranslate="reset.request.form.button" style="color: #727070; font-weight: 700; font-size: 1.3rem"
data-cy="submit" jhiTranslate="reset.request.title"
> >
Reset RESET YOUR PASSWORDD
</button> </h4>
</form> <p class="mb-4" style="color: rgba(146, 146, 146, 0.664)" jhiTranslate="reset.request.messages.info">
Enter the email address you used to register.
</p>
</div>
<div>
<div class="alert alert-success" *ngIf="success">
<span jhiTranslate="reset.request.messages.success">Check your emails for details on how to reset your password.</span>
</div>
<div class="alert alert-danger" *ngIf="errorEmailNotExists" jhiTranslate="reset.request.messages.error.emailnotexists">
<strong>Email no exists!</strong> Please choose another one.
</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>
<input
type="email"
class="form-control"
id="email"
name="email"
placeholder="{{ 'global.form.email.placeholder' | translate }}"
formControlName="email"
data-cy="emailResetPassword"
#email
/>
<div
*ngIf="
resetRequestForm.get('email')!.invalid &&
(resetRequestForm.get('email')!.dirty || resetRequestForm.get('email')!.touched)
"
>
<small
class="form-text text-danger"
*ngIf="resetRequestForm.get('email')?.errors?.required"
jhiTranslate="global.messages.validate.email.required"
>
Your email is required.
</small>
<small
class="form-text text-danger"
*ngIf="resetRequestForm.get('email')?.errors?.email"
jhiTranslate="global.messages.validate.email.invalid"
>
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>
<div class="row justify-content-center">
<button
type="button"
id="cancel-save"
data-cy="entityCreateCancelButton"
class="ds-btn ds-btn--secondary"
(click)="previousState()"
>
<fa-icon icon="arrow-left"></fa-icon>&nbsp;&nbsp;<span jhiTranslate="entity.action.back">Volver</span>
</button>
<button
type="submit"
[disabled]="resetRequestForm.invalid"
class="ds-btn ds-btn--primary"
jhiTranslate="reset.request.form.button"
data-cy="submit"
>
Reset
</button>
</div>
</form>
</div>
<!-- end card-body -->
</div>
<!-- end card -->
<div class="row mt-3">
<div class="col-12 text-center">
<p class="text-muted">
¿Aún no se encuentra registrado/a?
<a routerLink="/account/register" class="text-muted ms-1"><b>Crea una cuenta</b></a>
</p>
</div>
<!-- end col -->
</div>
<!-- end row -->
</div>
<!-- end col -->
</div> </div>
<!-- end row -->
</div> </div>
<!-- end container -->
</div> </div>
<!-- end page -->

View File

@ -2,6 +2,8 @@ import { Component, AfterViewInit, ElementRef, ViewChild } from '@angular/core';
import { FormBuilder, Validators } from '@angular/forms'; 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 { EMAIL_NOT_EXISTS_TYPE } from '../../../config/error.constants';
@Component({ @Component({
selector: 'jhi-password-reset-init', selector: 'jhi-password-reset-init',
@ -10,7 +12,8 @@ import { PasswordResetInitService } from './password-reset-init.service';
export class PasswordResetInitComponent implements AfterViewInit { export class PasswordResetInitComponent implements AfterViewInit {
@ViewChild('email', { static: false }) @ViewChild('email', { static: false })
email?: ElementRef; email?: ElementRef;
errorEmailNotExists = false;
error = false;
success = false; success = false;
resetRequestForm = this.fb.group({ resetRequestForm = this.fb.group({
email: ['', [Validators.required, Validators.minLength(5), Validators.maxLength(254), Validators.email]], email: ['', [Validators.required, Validators.minLength(5), Validators.maxLength(254), Validators.email]],
@ -25,6 +28,22 @@ export class PasswordResetInitComponent implements AfterViewInit {
} }
requestReset(): void { requestReset(): void {
this.passwordResetInitService.save(this.resetRequestForm.get(['email'])!.value).subscribe(() => (this.success = true)); this.errorEmailNotExists = false;
this.passwordResetInitService.save(this.resetRequestForm.get(['email'])!.value).subscribe(
() => (this.success = true),
response => this.processError(response)
);
}
previousState(): void {
window.history.back();
}
processError(response: HttpErrorResponse): void {
if (response.status === 400 && response.error.type === EMAIL_NOT_EXISTS_TYPE) {
this.errorEmailNotExists = true;
} else {
this.error = true;
}
} }
} }

View File

@ -2,8 +2,8 @@
"activate": { "activate": {
"title": "Activación", "title": "Activación",
"messages": { "messages": {
"success": "<strong>Su cuenta ha sido activada.</strong> Por favor, ", "success": "<strong>Su cuenta ha sido activada.</strong> Ya puede ",
"error": "<strong>Su cuenta no pudo ser activada.</strong> Por favor, utilice el formulario de inscripción para registrarse." "error": "<strong>Su cuenta no pudo ser activada.</strong> Por favor, regístrese en DataSurvey."
} }
} }
} }

View File

@ -65,7 +65,8 @@
"authenticated": { "authenticated": {
"prefix": "Si desea ", "prefix": "Si desea ",
"link": "iniciar sesión", "link": "iniciar sesión",
"suffix": ", puede intentar con las cuentas predeterminadas:<br/>- Administrador (usuario=\"admin\" y contraseña=\"admin\") <br/>- Usuario (usuario=\"user\" y contraseña=\"user\")." "suffix": ", puede intentar con las cuentas predeterminadas:<br/>- Administrador (usuario=\"admin\" y contraseña=\"admin\") <br/>- Usuario (usuario=\"user\" y contraseña=\"user\").",
"botonInicio": "Iniciar Sesión"
}, },
"register": { "register": {
"noaccount": "¿Aún no tienes una cuenta?", "noaccount": "¿Aún no tienes una cuenta?",

View File

@ -7,7 +7,10 @@
}, },
"messages": { "messages": {
"info": "Introduzca la dirección de correo electrónico que utilizó para registrarse", "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." "success": "Revise su correo electrónico para obtener más información sobre cómo restablecer su contraseña.",
"error": {
"emailnotexists": "<strong>¡El correo electrónico no se encuentra registrado en el sistema!</strong> Por favor, ingrese otro email."
}
} }
}, },
"finish": { "finish": {