Skip to content

Auth: Implement User Registration & Login Flow #3

@cliffdoyle

Description

@cliffdoyle

A user must be able to create an account and log in securely. Sessions are managed by Redis.

Backend Tasks:

  • Create a /api/register endpoint that takes user details, hashes the password (use bcrypt), and saves to the users table.
  • Create a /api/login endpoint that validates credentials.
  • On successful login, generate a random session token, store {user_id, role} in Redis with the token as the key, and set a 24h expiry.
  • Create an authentication middleware that protects routes. It must check for a Authorization: Bearer header, validate the token against Redis, and pass user info into the request context.

Frontend Tasks:

  • Create a RegisterPage.jsx component with a form that calls the /api/register endpoint.
  • Create a LoginPage.jsx component with a form that calls the /api/login endpoint.
  • On successful login, store the session token in a secure HttpOnly cookie or localStorage.
  • Configure your Axios instance to automatically include the token in all future requests.
  • Implement a ProtectedRoute component that redirects to /login if no user is authenticated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions