Question

I'm wanting to make a 'before' hook for a certain page that will see if a user is signed in first and if not render/redirect to the sign-in page... now, should I use redirect or render for this?

I know this question is probably a more general question but I guess it would be helpful to know the difference between the two and when to use them..

Was it helpful?

Solution

The basic difference is that render will simply render the passed in template for whatever route the user landed on when the before hook was called, and redirect will change the route and render the template associated with the new route.

You can use either...just depends on what you want to accomplish. Sometimes you might want to allow the user to sign in from any page and then stay on that page...so, you would use a render. Other times, you want to send them to a sign-in route and then direct them to specific route following a successful sign-in...in that case, you'd perform a redirect.

Clear as mud?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top