Skip to content

Redirect unauthenticated users to the /login page #20

@svedova

Description

@svedova

Context

If a user has no session, redirect them to the /login page.

Backend

  • When the user logs in, we need to set a JWT token (we can use https://www.npmjs.com/package/jose, feel free to pick another popular library)
  • A GET /api/session endpoint can return the user object (or jwt token) so that it's easier for the frontend to check if the user is logged in or not.
  • All other API requests must pass an Authentication header with the bearer token. See example:
Authorization: Bearer <my-bearer-token>

If the authentication fails, these endpoints will return a 401 Unauthorized.

Frontend

  • We can add an Auth context that wraps the whole application. This Auth will check if the user is logged in or not. If not, it will redirect the user to the /login page.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions