You didn't update the action of the login form, so it's trying to post to
the URL of the page it is on. Should be:
auth.login().update(_action=URL('default', 'user', args='login'), ...)
or whatever your login URL is.
Anthony
On Tuesday, June 4, 2013 6:33:28 PM UTC-4, lesssugar wrote:
>
> OK, I have this in my view:
>
> {{if not auth.user:}}
> {{auth.settings.login_next = URL('default', 'test')}}
> {{=auth.login().update(_name='global_login')}}
> <a href="#" id="pass_reset">Forgot password?</a>
> {{else:}}
> <a href="{{=URL('default', 'user', args='logout')}}"
> class="golden">Logout</a>
> {{pass}}
>
> As you say, if login data are correct, user should be automatically logged
> in and [in this case] redirected to default/test.
>
> But when I put (just to test) im my default.py:
>
> @auth.requires_login()
> def test():
> return dict(message='you are logged in')
>
> and then I try to log in with 100% correct data I am "redirected" to
> [appname]/#
>
> So no redirection is taking place, neither is logging in (checked it:
> auth.user is False after submitting the form).
>
> Any suggestions? I'm surely doing something wrong and it's supposed to be
> automatic and easy ;)
>
>
>
>
> On Tuesday, June 4, 2013 7:47:41 PM UTC+2, Anthony wrote:
>>
>> The auth.login() action automatically verifies the login and logs the
>> user in (which involves adding the user record to the user's session) --
>> you don't have to do any of that explicitly. If you want to redirect to a
>> specific URL after login, you can set auth.settings.login_next to the
>> desired URL. Another option is to use auth.settings.login_onaccept, which
>> is a function that takes the login form object (after it has been
>> processed).
>>
>> Anthony
>>
>> On Tuesday, June 4, 2013 1:13:47 PM UTC-4, lesssugar wrote:
>>>
>>> In my layoyt.html I have the following code
>>>
>>> {{=auth.login().update(_action=URL('default', 'login'), _name=
>>> 'global_login')}}
>>>
>>> The login form takes user email and password. It generates correctly.
>>> Let's assume there are test users in db.auth_user.
>>>
>>> I would be grateful if someone provided a short example of further login
>>> implementation:
>>> 1. validate the login data (is email in db? is password correct?)
>>> 2. if data OK: redirect to a specific user profile
>>>
>>
--
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.