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

Auth/reset password and some auth changes #1768

Merged
merged 23 commits into from
Feb 23, 2024
Merged

Auth/reset password and some auth changes #1768

merged 23 commits into from
Feb 23, 2024

Conversation

siddhantk232
Copy link
Contributor

@siddhantk232 siddhantk232 commented Feb 14, 2024

This PR introduces a reset-password feature:

  • Authenticated users can change their password by going to /-/auth/set-password/
  • Unauthenticated (logged out) users can request password reset by goind to /-/auth/forgot-password/. This sends an email with a link to set their password.

Auth changes

  • /-/auth/create-account/: requires two new json body params, password2 and accept_terms. See the integration tests to learn what has changes in request body.
  • /-/auth/create-account/: redirect to /-/auth/resend-confirmation-email/ on successful requests. This same route can be used to re-request confirmation emails in cases where user does not receive email.
  • FASTN_ENABLE_EMAIL: new environment variable for use during development. This will be used to log emails to the console instead of actually sending it. This removes the need of FASTN_SMTP* environment variables.
  • req_config.request.ud() checks on server session before returning the user. This enables invalidation of logged in users on password reset.

Refactor

  • Route enum to keep track of auth related routes.

What happens when a github user tried to reset their password?

The /-/auth/set-password, used when authenticated, converts their github oauth account to a normal email_password account. After doing this, they can use both the github login and the email_password login method.

Same goes for /-/auth/forgot-password/, entering their github username/email will send an email with a link to set their password. Check https://github.com/siddhantk232/fastn-test-multiauth to test things out.

@siddhantk232 siddhantk232 marked this pull request as draft February 14, 2024 10:00
siddhantk232 added a commit to siddhantk232/fastn-test-multiauth that referenced this pull request Feb 20, 2024
@siddhantk232 siddhantk232 changed the title Auth/reset password Auth/reset password and some auth changes Feb 20, 2024
@siddhantk232 siddhantk232 marked this pull request as ready for review February 20, 2024 15:04
@siddhantk232 siddhantk232 requested a review from amitu February 20, 2024 15:05
@amitu
Copy link
Contributor

amitu commented Feb 22, 2024

@siddhantk232 there are some conflicts, please resolve. We have switched to using .starttls_relay() (SMTP with StartTLS extension) as it seems neither AWS SES, nor postmark work with .relay() (SMTPS). Ideally we should make both protocol and port configurable.

@siddhantk232
Copy link
Contributor Author

There's a way to disable sending emails in dev mode (using FASTN_ENABLE_EMAIL) so we can live with .starttls_relay() for a short while. I'll later add more options for these in mail.rs

@amitu amitu requested a review from Arpita-Jaiswal February 22, 2024 14:08
`/-/auth/create-account/` redirects to this route for sending email.
users can also use this to request email again in case they did not
receive it the first time
@Heulitig Heulitig merged commit 4fd0b6d into main Feb 23, 2024
1 check passed
@Heulitig Heulitig deleted the auth/reset-password branch February 23, 2024 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants