Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialLuke Ward
9,154 PointsBest practice for displaying login page after unsuccessful login?
After watching the authentication with express videos and following along, I was curious about best practices for redisplaying the login page after an unsuccessful loging. In the videos after the router handler handles the POST request to the /login route and finds a bad login we throw an error which ends up rendering the error page.
Would it be possible to rather than throwing an error to instead call res.render("/login/) and pass Res.locals variable to show a bad login or to redirect back to /login with a query string to show a bad login.
1 Answer
Zimri Leijen
11,835 PointsYes, that would be possible, and I think that would be a good user experience.