Implement a redirect mechanism to direct users to specific routes based on the presence of a login token.
Specifications
1. Check for Login Token
Check whether a valid login token exists for the user.
2. Redirect Logic
If a valid login token is present, redirect the user to the '/sheets' route.
If there is no valid login token, redirect the user to the '/' (root) route.
3. Handling Existing Routes
Ensure that this redirect logic works in conjunction with any existing routing and does not disrupt other routes.
4. Token Validation
Verify that the token is valid and not expired before performing the redirect. If the token is invalid or expired, handle it accordingly (e.g., log the user out).
5. HTTP Status Codes
Use appropriate HTTP status codes for the redirects. A common choice is a 302 Found for a temporary redirect.
6. Testing
Thoroughly test the redirect logic to confirm that users are directed to the correct route based on the presence of a login token.
Adding Redirects Based on Login Token Presence
Objective
Implement a redirect mechanism to direct users to specific routes based on the presence of a login token.
Specifications
1. Check for Login Token
2. Redirect Logic
3. Handling Existing Routes
4. Token Validation
5. HTTP Status Codes
6. Testing