Closed flash548 closed 3 years ago
Ah, excellent idea! Thanks!
Actually, now that I think about it, is this a better default behavior? Redirecting the user to a login page instead of displaying a login page on any URL?
Might be better default behavior... but might depend on the app too. Probably wouldn't hurt to leave both (params and flash) in there?
Yeah, I was thinking for the require_user
auth check it could start redirecting the user instead of the current behavior of returning an unauthorized response with the login form, but now that I think about it that doesn't really sound right either: Returning a redirect code instead of a response error code would be technically incorrect... So, I just documented some of the options and maybe I'll rethink some of the API as I move things over to using Yancy::Model.
Thanks again!
This change checks the flash if
return_to
value not found in the req->params. This was wanted to be able to set thereturn_to
value after a redirect. Before only could force a query parameter (e.g./yancy/auth/password?return_to=/other-page
).Now can do something like this in your app if you're trying to protect routes, and an unauthenticated user tries to hit a protected path: