Skip to content

No protected route page after successful sign in #1

Closed
@aabbtree77

Description

@aabbtree77

First of all, thank you for this code and your amazing youtube tutorials. In the year 2024 the whole node.js ecosystem still does not have a standard RoR/Django type of server side authentication library, it is unbelievable how bad this is! So you are doing a great work in the right direction.

I noticed there is still a problem with the code. After signing in, the toast will always briefly show "Signed in successfully", but the page with the protected route may not be displayed. I need to hit Chrome's "Refresh" to get to that page at times. The browser's address still shows "http://localhost:3000/sign-in" instead of "http://localhost:3000/" despite the browser's console showing that router.push("/"); is executed inside components/singInForm.tsx.

Drizzle Studio shows the session is created, but I am still on the sign-in page when this happens. If I don't press "Refresh", but click again on sign-in or I enter a wrong username/password, all sorts of bugs will occur, multiple sessions, runtime errors...

Adding console.log(user) inside "export default async function Home() {" inside app/page.tsx shows that this function is not reached after "Signed in successfully" when the bug occurs.

This happens mostly when I do a quick sign in after a sign out, mostly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions