Should we offer something like {{=auth.ajax_login()}} helper which submits
to /user/login? If would not be difficult to write.
How should it work?
On Sunday, 17 February 2013 21:37:59 UTC-6, Anthony wrote:
>
> def login():
>
> form=auth.login()
>> if form.accepts(request,session=None):
>>
>
> auth.login() already handles form processing, so you should not call
> form.accepts(), as that will not work.
>
>
>> <form action=''>
>> <fieldset>
>> <div id='login_result'></div>
>> <label>Email</label>
>> <input name='email' id='email' type="text" placeholder="Email
>> Address">
>> <label>Password</label>
>> <input name='password' id='password' type="password"
>> placeholder="*********"><br/>
>> <button id='loginbtn' class="btn" Onclick='login();return
>> false;'>Submit</button>
>> </fieldset>
>> </form>
>>
>
> web2py SQLFORM's (including the auth forms) include hidden _formname and
> _formkey fields -- if you're creating a custom form, you need to include
> those, or the form will not pass validation when submitted. If you want to
> create a custom form based on a SQLFORM, you should follow
> http://web2py.com/books/default/chapter/29/07#Custom-forms.
>
> Also, rather than manually submitting the form via Ajax, you might
> consider putting the login form in an Ajax component (or even a non-Ajax
> component with ajax_trap set to True). In that case, web2py.js will handle
> the Ajax submission for you. In that case, you may want to create a
> login_onaccept function to avoid the usual post-login redirect (which
> wouldn't be useful for an Ajax login).
>
> Anthony
>
--
---
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.