Skip to content
This repository has been archived by the owner on Sep 10, 2024. It is now read-only.

Add Self-service Password Change #2863

Merged
merged 15 commits into from
Jun 25, 2024
Merged

Add Self-service Password Change #2863

merged 15 commits into from
Jun 25, 2024

Conversation

Copy link

cloudflare-workers-and-pages bot commented Jun 20, 2024

Deploying matrix-authentication-service-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2c8ed61
Status: ✅  Deploy successful!
Preview URL: https://0e588458.matrix-authentication-service-docs.pages.dev
Branch Preview URL: https://rei-fe-pw-change.matrix-authentication-service-docs.pages.dev

View logs

@reivilibre reivilibre marked this pull request as ready for review June 21, 2024 21:40
@reivilibre reivilibre requested a review from sandhose June 21, 2024 21:41
Copy link
Member

@sandhose sandhose left a comment

Choose a reason for hiding this comment

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

A few things here and there, but that looks really nice!

frontend/locales/fr.json Outdated Show resolved Hide resolved
flex: 1;
}

.link {
Copy link
Member

Choose a reason for hiding this comment

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

There is an existing Link component which should have the same style?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I stole this from UserEmail FWIW

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the Link component does not have the underline or the white text colour, it just looks like plain grey text

Copy link
Member

Choose a reason for hiding this comment

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

Fundamentally we're missing a good implementation of the Text Link component: https://www.figma.com/design/rTaQE2nIUSLav4Tg3nozq7/Compound-Web-Components?node-id=645-3494&t=OH2MjoxKqsJTB1vF-4

I'll leave the duplication for now, and will see to implement that in Compound

frontend/src/routes/_account.index.tsx Outdated Show resolved Hide resolved
frontend/src/routes/password.change.tsx Outdated Show resolved Hide resolved
frontend/src/routes/password.change.tsx Outdated Show resolved Hide resolved
Comment on lines 127 to 138
case SetPasswordStatus.NoCurrentPassword:
return t(
"frontend.password_change.failure.description_NO_CURRENT_PASSWORD",
);
case SetPasswordStatus.NotAllowed:
return t("frontend.password_change.failure.description_NOT_ALLOWED");
case SetPasswordStatus.NotFound:
return t("frontend.password_change.failure.description_NOT_FOUND");
case SetPasswordStatus.PasswordChangesDisabled:
return t(
"frontend.password_change.failure.description_PASSWORD_CHANGES_DISABLED",
);
Copy link
Member

Choose a reason for hiding this comment

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

Actually for those I would just throw within the component? None of those are not recoverable by the user, so showing a page 'crash' is probably the best thing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

some of these I'm on the fence about.

e.g. password change disabled: the functionality could have been disabled since you navigated to the page, it feels a bit crap to show a generic 'something went wrong' error when we know the actual reason.

not allowed / not found: these probably make more sense if we had an admin control panel in MAS, but agreed we can probably lose them

no current password: I'd be tempted to keep it, since it's explanatory of a real-world error you might hit?

frontend/src/routes/password.change.tsx Outdated Show resolved Hide resolved
frontend/src/routes/password.change.tsx Outdated Show resolved Hide resolved
frontend/src/routes/password.change.tsx Outdated Show resolved Hide resolved
@reivilibre reivilibre requested a review from sandhose June 24, 2024 16:39
Copy link
Member

@sandhose sandhose left a comment

Choose a reason for hiding this comment

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

A few nitpicks but we're almost there!

frontend/src/routes/password.change_success.tsx Outdated Show resolved Hide resolved
Comment on lines 27 to 36
const CURRENT_VIEWER_QUERY = graphql(/* GraphQL */ `
query CurrentViewerQuery {
viewer {
__typename
... on Node {
id
}
}
}
`);
Copy link
Member

Choose a reason for hiding this comment

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

Arguably, we don't need to load the current user as we're not really displaying anything about them, but I guess we need this for showing a 404 if the user isn't logged in. Also that query is most certainly cached so 🤷

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah I was on the fence about this one...

Comment on lines 267 to 274
{handleableError && (
<Alert
type="critical"
title={t("frontend.password_change.failure.title")}
>
{errorMsg}
</Alert>
)}
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I like the switch/case logic up there. Because we have some errors specific to fields, I would rather have a series of {result.data?.setPassword.status === SetPasswordStatus.NoCurrentPassword && (<Alert … />)}. wdyt?

Also could you stick alerts at the top of the form?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

do you think we should not show the errors in an alert if they are specific to a form field? I was thinking that might make it a bit harder to notice but wasn't entirely sure.

Both the switch and the sequence of conditionally rendered alerts feel a bit tedious but struggling to think of anything better

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that said: I think it's important to have a 'default' case (for unhandled errors etc) and by taking your approach, it's harder to see how we'd do that

Copy link
Member

Choose a reason for hiding this comment

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

do you think we should not show the errors in an alert if they are specific to a form field? I was thinking that might make it a bit harder to notice but wasn't entirely sure.

Yep, as radix forms will take care of focusing the errored field. I don't think I've saw any form with an alert like that in the designs

that said: I think it's important to have a 'default' case (for unhandled errors etc) and by taking your approach, it's harder to see how we'd do that

that's a fair point. Although could be offset by doing something like:

  const status = result.data?.setPassword.status;
  switch (status) {
    // Cases that are handled by the form
    case SetPasswordStatus.InvalidNewPassword:
    case SetPasswordStatus.NoCurrentPassword:
    case SetPasswordStatus.PasswordChangesDisabled:
    case SetPasswordStatus.WrongPassword:
    case SetPasswordStatus.Allowed:
    case undefined:
      break;

    case SetPasswordStatus.NotFound:
    case SetPasswordStatus.NotAllowed:
      throw new Error(`unexpected error when changing password: ${status}`);

    default:
      unreachable(status);
  }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This means you then have to remember to keep that in sync with what the form shows. I wouldn't mind something different but I prefer to make sure that handling the error and knowing we handle the error are guaranteed to be the same

frontend/src/routes/password.change.tsx Outdated Show resolved Hide resolved
@reivilibre reivilibre requested a review from sandhose June 25, 2024 11:04
Copy link
Member

@sandhose sandhose left a comment

Choose a reason for hiding this comment

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

I'm fine with the double-error message for now, will see during design review I guess wether we should change that or not

@reivilibre
Copy link
Contributor Author

I updated the double-error thing to not show, if it does focus like you say then I think my concern has been dealt with. I also find it a bit weird to double-show so on balance I'll go with this for now.

@reivilibre reivilibre enabled auto-merge (squash) June 25, 2024 12:56
@reivilibre reivilibre merged commit aaa7cf3 into main Jun 25, 2024
16 checks passed
@sandhose sandhose mentioned this pull request Jul 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better UI for self-served password change
2 participants