-
Notifications
You must be signed in to change notification settings - Fork 286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Protect the routes!!! #12
Comments
@Kiranism You can protect routes by calling |
Yeah, that will work. Maybe that can be added to the code. |
It's already in the code. The dashboard page uses the |
It just throwing an error. Please check this picture #12 (comment) |
@Kiranism I see. There were a few issues I had to solve to get this template work on production. I'll check that out. |
I think having a method called assertAuthenticatedAndRedirect('/your/url') would be my recommendation. I personally don't like when a user is just randomly redirected to a new page; I'd rather show them an error so they know not to do it again. I can look into this error difference between prod and dev and try to update this. |
I concur with that strategy. |
Fair enough. I also noticed that you can still visit the login page (auth routes) after signing in, which can be avoided with a similar check." |
@webdevcody Hey, what can we do to protect the routes? Since we aren't using middleware, maybe we can do the checks directly in the pages?
something like
export default async function Dashboard() { const user = await getUser(); if (!user) { return redirect('/admin/login'); } return (...)
The text was updated successfully, but these errors were encountered: