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: express endpoints for mail verification and password reset #1262

Closed
wants to merge 2 commits into from

Conversation

darkbasic
Copy link
Member

image

There were no endpoints to allow the user to validate the email or reset the password, so I created them.
Doing the email validation call directly from the client wasn't an option because it's not realistic to expect the user to manually type such a long token so instead he can simply click on the link in the email and he will be greeted by some static html confirming or denying the process.
Password reset on the other hand requires the user to type a new password so he will be presented with a static html form that in turn will call another REST endpoint that gets the job done. Again it is not realistic to expect the user to type such a long token, so with the client taken out of the equation the only other option would be to generate a new password from the backend instead of letting the user choose his own. This would still require a rest endpoint and it would negate the flexibility of letting the user choose his own password.
These endpoints can be used by both rest and graphql users. The graphql-yoga example shows how to create an express app which makes use of these endpoints and delegates the /graphql path to yoga for graphql.

Copy link

changeset-bot bot commented Nov 16, 2023

🦋 Changeset detected

Latest commit: ccf35ee

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@accounts/password Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

router.use(express.urlencoded({ extended: true }));

router.use(infosMiddleware);
router.get('/verify-email/:token', verifyEmail(app.injector));

Check failure

Code scanning / CodeQL

Missing rate limiting High

This route handler performs
authorization
, but is not rate-limited.
Copy link
Contributor

github-actions bot commented Nov 16, 2023

💻 Website Preview

The latest changes are available as preview in: https://663afe5a.accounts-js.pages.dev

Copy link

codecov bot commented Nov 16, 2023

Codecov Report

Attention: 27 lines in your changes are missing coverage. Please review.

Comparison is base (9cecbdd) 93.98% compared to head (e3aba87) 93.00%.
Report is 3 commits behind head on master.

❗ Current head e3aba87 differs from pull request most recent head ccf35ee. Consider uploading reports for the commit ccf35ee to get more accurate results

Files Patch % Lines
packages/password/src/endpoints/express.ts 19.35% 22 Missing and 3 partials ⚠️
packages/password/src/accounts-password.ts 80.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1262      +/-   ##
==========================================
- Coverage   93.98%   93.00%   -0.99%     
==========================================
  Files         114      116       +2     
  Lines        2428     2473      +45     
  Branches      542      556      +14     
==========================================
+ Hits         2282     2300      +18     
- Misses        136      159      +23     
- Partials       10       14       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines +49 to +56
getHtml(
'Email verification error',
`
<h3>The email address couldn't be verified: ${err.message ?? 'unknown error'}</h3>
`
)

Check warning

Code scanning / CodeQL

Exception text reinterpreted as HTML Medium

Exception text
is reinterpreted as HTML without escaping meta-characters.
Comment on lines +79 to +87
getHtml(
'Password reset error',
`
<h3>The password couldn't be changed: ${err.message ?? 'unknown error'}</h3>
`
)

Check warning

Code scanning / CodeQL

Exception text reinterpreted as HTML Medium

Exception text
is reinterpreted as HTML without escaping meta-characters.
packages/password/src/endpoints/express.ts Fixed Show fixed Hide fixed
@darkbasic darkbasic force-pushed the graphql-rest branch 2 times, most recently from db804c6 to a87a21c Compare November 16, 2023 11:34
@darkbasic darkbasic closed this in e3aba87 Nov 16, 2023
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.

1 participant