Sorry about the bad chose of words. "The only reason" is not correct. There 
are always exceptions, but in your case it's still valid:

1) You go to /login
2) You enter invalid login credentials and submit to /login
3) Mojolicious render /login
4) You enter correct login credentials and submit to /login
5) Mojolicious redirect you to /profile (or something else that's not 
/login)

Step #5 redirects and avoids the "do you want to repost the form" issue. 
You do not want to redirect on step #3, since that will make it much harder 
to prefill the form. In addition it adds extra load to the webserver, 
without adding any value. (At least I don't see any added value)

Here is another case:

1) You go to /profile, but you're not logged in
2) Mojolicious render the login form, with a hidden field with the original 
path "/profile".
3) You enter correct login credentials and submit to /login
4) Mojolicious redirect you to /profile

Step #4 redirects and avoids the "do you want to repost the form" issue. 
You might also want to do a redirect on step #1 to 
/login?redirect_uri=/profile. This redirect will be done anyway, if you use 
third party login services.


On Tuesday, July 28, 2015 at 1:37:41 AM UTC+2, Stefan Adams wrote:
>
>
> On Fri, Jul 24, 2015 at 4:07 AM, Jan Henning Thorsen <
> [email protected]> wrote:
>
>> The only reason to do a redirect is when you want to avoid the "do you 
>> want to repost the form" when someone click the "refresh wheel" or F5.
>
>
> Or if you care about the URL.  Is this a stupid reason?  If I find myself 
> doing redirects instead of renders for this reason too frequently am I 
> doing it wrong?  That is, do I really need my users seeing the URL as 
> /login as opposed to /profile if they aren't logged in?  Or, is this off 
> topic from form validation?
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to