Rainbow-Devs / health-tracker-frontend

The Next.js-based frontend webapp for the Rainbow Devs Health Tracker application.
MIT License
1 stars 6 forks source link

(Authentication State) Redirect User on Login or prevent logging in if already a user #44

Open justEstif opened 1 year ago

justEstif commented 1 year ago

Describe the Feature / Enhancement

Currently, after users log in, they are not redirected to a specific page based on their authentication state.

This feature should be implemented to redirect users to the appropriate page upon login or visit, based on their authentication state.

To implement this feature, the following steps are suggested:

  1. When a user visits the website, check if they are already logged in.
    • If a user is logged in, prevent them from being redirected to the login page and update the navigation bar to reflect their authenticated state.
  2. Upon successful login, retrieve the user's authentication state.
  3. Determine whether the user is a new user or a returning user based on their authentication state.

    • If the user is identified as a new user, redirect them to the /goals page.
    • If the user is recognized as a returning user, redirect them to the /profile page, which serves as the default landing page for returning users.

Additional Details and Resources

Consider the following points to ensure successful implementation:

Git Instructions:

git fetch origin
git checkout 44-redirect-user-on-login

Correct Project Selected

Correct Label Selected

Correct Milestone Selected

andersjbe commented 1 year ago

Waiting for story 39 to be merged so the frontend has access to the cookie with the user data after login