Skip to content

Login-by-email feature and supporting infrastructure #23

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

Merged
merged 118 commits into from
Mar 10, 2025

Conversation

tomast1337
Copy link
Member

@tomast1337 tomast1337 commented Dec 25, 2024

This pull request implements email-based authentication and adds necessary supporting services and infrastructure.

Authentication & Email Features:

  • Implement login-by-email using passport-magic-login
  • Add email verification flow with handlebars templates
  • Create MagicLinkEmailStrategy for email authentication
  • Introduce MailService for SMTP email handling
  • Add routes for email login and verification
  • Add a username change option in the menu with the corresponding route

Infrastructure Updates:

  • Add MinIO (self-hosted S3 alternative) services to docker-compose-dev.yml
  • Add maildev service to docker-compose-dev.yml for local email testing
  • Update EnvironmentVariables with new configs and validation

Technical Improvements:

  • Refactor dependency injection to use useFactory and inject (Nest.js upgrade compatibility)
  • Update login page UI to include email login option

Documentation Updates:

  • CONTRIBUTING.md: The setup instructions have been updated to use docker-compose-dev.yml instead of docker-compose.yml. Additional environment variables and detailed setup instructions for both the backend and frontend have been added. New sections for running only the backend or frontend, populating the database with test data, and running tests have been included.

@tomast1337
Copy link
Member Author

tomast1337 commented Jan 4, 2025

Just a reminder

TODO:

  • If a new account has not been validated in some time, delete the account from the database (or only register the user when they 'return' with the token from the magic link)
  • Add time limit (15 min-1 hour) to magic link login
  • Add documentation in CONTRIBUTING.md for email and seed modules (e.g. seed routes only work in development mode)
  • Format the email body a bit more nicely
  • Local environment is not using mocked S3 URL (thumbnail URL is hardcoded to Backblaze in FileService, such that songs are always saved with this URL in the database)
  • Rate-limit login by email route
  • Front-end: redesign sign in page putting priority in magic link login
  • Front-end: unify login form adding email field and 'Submit' button
  • Add a notice on the front end about link expiration (e.g. A magic link has been sent to [email]! It will stay valid for one hour.)
  • Remove auth/register backend route and use only auth/magic-link route; if the user doesn't exist, create it and use the email slug as username
  • Add pencil in the user info popup so they can change their username
  • Token cookie maxAge is provided in ms, not in seconds (verify this)

…gin links
…mprove email context handling
@tomast1337
Copy link
Member Author

  • Format the email body a bit more nicely

New account email
image

Verified and existing account email:
image

CSS in emails has many limitations. It can be improved somehow still.

… codebase
…k for Axios errors
@Bentroen
Copy link
Member

Bentroen commented Jan 6, 2025

Thanks for implementing these changes! The email template looks great now.

I'll still review the frontend and likely do some small changes, though I'm only able to do that after about the 22nd this month. Let me know when you're done with your changes :)

@tomast1337
Copy link
Member Author

Currently, the rate limit is one login email per hour, this can be tweaked to a better-fitting value.

image

@tomast1337 tomast1337 changed the title Feature/login by email WIP Feature/login by email Jan 12, 2025
@tomast1337 tomast1337 changed the title Feature/login by email feat: Add login-by-email feature and supporting infrastructure Jan 12, 2025
@Bentroen Bentroen self-requested a review January 17, 2025 17:24
…nto feature/login-by-email
@Bentroen Bentroen changed the title feat: Add login-by-email feature and supporting infrastructure Login-by-email feature and supporting infrastructure Feb 19, 2025
@Bentroen
Copy link
Member

Bentroen commented Mar 3, 2025

This PR is waiting on us setting up an email server to be merged. :)

@tomast1337
Copy link
Member Author

This PR is waiting on us setting up an email server to be merged. :)

I feel it would be good to merge and maybe disable the email server-related feature until it's available.

…nto feature/login-by-email
@tomast1337 tomast1337 merged commit b7a5f49 into develop Mar 10, 2025
2 checks passed
@github-project-automation github-project-automation bot moved this from Pending Review to Done in Public Roadmap | Note Block World Mar 10, 2025
Bentroen added a commit that referenced this pull request May 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants