Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dev-portal): add reset password #10659

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

naouf4l-grav
Copy link
Contributor

@naouf4l-grav naouf4l-grav commented Feb 14, 2025

Issue

https://gravitee.atlassian.net/browse/APIM-4338

Description

Add reset password feature.

Additional context

Capture d’écran 2025-02-14 à 11 07 34 Capture d’écran 2025-02-14 à 11 08 02 Capture d’écran 2025-02-14 à 11 09 14 Capture d’écran 2025-02-14 à 11 10 09 Capture d’écran 2025-02-14 à 11 10 34 Capture d’écran 2025-02-14 à 11 11 02

📚  View the storybook of this branch here

@naouf4l-grav naouf4l-grav requested a review from a team as a code owner February 14, 2025 09:44
@naouf4l-grav naouf4l-grav force-pushed the APIM-4338-add-reset-password branch from a72c72b to 5069da0 Compare February 14, 2025 09:57
@naouf4l-grav naouf4l-grav force-pushed the APIM-4338-add-reset-password branch from 5069da0 to 2d251dd Compare February 14, 2025 10:04
@naouf4l-grav naouf4l-grav changed the title feat: add reset password feat(dev-portal): add reset password Feb 14, 2025
Copy link
Contributor

@jourdiw jourdiw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments for your PR.

Additionally for the UI, we can improve it with what we mentioned in the call.

@@ -50,6 +50,9 @@
Log in
</button>
</mat-card-actions>
<mat-card-content>
<a class="log-in__form__reset" routerLink="/reset-password">Forget password?</a>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<a class="log-in__form__reset" routerLink="/reset-password">Forget password?</a>
<a class="log-in__form__reset" routerLink="/reset-password">Forgot password?</a>

Also, since you have hard-coded text, you can add i18n="@@someUniqueIdHere" to this tag 👍

&__reset {
display: flex;
justify-content: center;
color: #0f0e11;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to reference a variable in the variables.scss rather than hard-coding the color here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here: is there a variable that you can reference for the colors in variables.scss ?

Also, having a fixed-width in pixels might make things difficult for adapting to screens. Could you specify the width in a percentage?

Comment on lines +155 to +159
{
path: 'reset-password/confirm/:token',
component: ResetPasswordConfirmationComponent,
canActivate: [redirectGuard, anonymousGuard],
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non blocking comment: This works, but just a heads up that since this shares the same root with the ResetPasswordComponent, you can nest it as a child of ResetPasswordComponent.

<mat-form-field class="reset-password__form__input">
<mat-label i18n="@@resetPasswordConfirmationConfirmedPassword">Confirmed Password</mat-label>
<input matInput formControlName="confirmedPassword" type="password" appearance="outlined" (input)="update1()" />
@if (resetPasswordConfirmationForm.controls['confirmedPassword'].hasError('passwordMismatch')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you are using a typed form, you can use some shortcuts 😉

Suggested change
@if (resetPasswordConfirmationForm.controls['confirmedPassword'].hasError('passwordMismatch')) {
@if (resetPasswordConfirmationForm.controls.confirmedPassword.hasError('passwordMismatch')) {


this.resetPasswordService
.resetPassword(this.resetPasswordForm.value.username, currentUrl)
.pipe(take(1))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heads up: best practice is to always include a takeUntilDestroyed(this.destroyRef) as the last step in a pipe. This guarantees that when the component is being destroyed, the subscription will be closed.

This can be done for the Observables across the other components you have added in this PR.

Comment on lines +23 to +24
console.log(password.value);
console.log(confirmedPassword.value);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗑️

Comment on lines +19 to +20
const password = control.parent?.get('password');
const confirmedPassword = control.parent?.get('confirmedPassword');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems fairly specific to how the ResetPasswordComponent works (aka. it needs a parent, and the parent control needs to have a password and confirmedPassword controls). Is there a way to make this more generic or if not, then to have it better placed in order to be scoped to the ResetPasswordComponent?

Comment on lines +30 to +32
httpClientMock = {
post: jest.fn().mockReturnValue(of({})),
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using mocks is fine, but we typically use the HttpTestingController to assess service calls. Specifically to test that:

  • the correct URL has been called
  • if it's a POST, the correct request body has been sent
  • verify that we do not call the same endpoint multiple times
  • verify that there are no requests outstanding

Could you please make sure to cover these points when using mock?

);
return JSON.parse(jsonPayload);
} catch (error) {
console.error('Failed to parse token:', error);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗑️

@naouf4l-grav naouf4l-grav marked this pull request as draft February 14, 2025 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants