Was fighting with the problem in 2011 and still do, how to log in with ajax?
The problem is that I have a one pager app with client site js code that 
needs to register if the user is logged in
when I login with e.g. 
index.html:
<div id="i-login-form"></div>


js code:
web2py_component(localconfig.baseurl + '/default/user.load/login', 
'i-login-form')

default.py unchanged from welcome app

user.load
{{=form}}

I have not found a way to register in the js code if the login was a 
success or fail

I modified web2py_component so that it has a callback that is executed 
every time the ajax call in web2py_ajax_page (via web2py_component) is 
completed

web2py_component(localconfig.baseurl + '/default/user.load/login', 
'i-login-form', undefined, undefined, function() {
        // do some other ajax call if the login was a success
});


But this is far from ideal. The callback code must check if this is the 
first call and if the login was a success. Also if the login failed (e.g. 
an email was provided but no password) no form is returned :(

Do I really have to write my own server side login methods to make this 
work? Any news on this?


On Friday, May 24, 2013 6:14:06 AM UTC+2, software.ted wrote:
>
> In addition, auth.login_bare() seems to check only with auth_user table, 
> if my authentication is based on LDAP it may not work. Any progress that 
> has been made  on auth.ajax_login()?
> On 24 May 2013 05:58, "Teddy Nyambe" <[email protected] <javascript:>> 
> wrote:
>
>> Why I asked cause a 2 months or so Massimo contributed to a similar 
>> thread and this is what he wrote:
>>
>> 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?
>>
>> The guy who hd asked a question on pure Ajax login had used 
>> auth.login_bare() and from my assessment he seemed to hv challenges with it.
>> On 24 May 2013 05:46, "Teddy Nyambe" <[email protected] <javascript:>> 
>> wrote:
>>
>>> Of course read the book, auth.login_bare() manages my sessions 
>>> automatically? Will check it out thanx
>>> On 23 May 2013 20:09, "Anthony" <[email protected] <javascript:>> wrote:
>>>
>>>> Basic authentication won't do anything with the session -- it requires 
>>>> sending the credentials on every request -- probably not what's desired 
>>>> here. Instead, the very next section in the book may help: 
>>>> http://www.web2py.com/book/default/chapter/09#Manual-Authentication. 
>>>> You can post the login credentials via Ajax and then use auth.login_bare() 
>>>> to handle the login.
>>>>
>>>> Anthony
>>>>
>>>> On Thursday, May 23, 2013 1:39:13 PM UTC-4, Derek wrote:
>>>>>
>>>>> You did read the book before you asked, yes?
>>>>>
>>>>> http://www.web2py.com/book/default/chapter/09#Access-
>>>>> Control-and-Basic-Authentication
>>>>>
>>>>> On Thursday, May 23, 2013 9:49:21 AM UTC-7, software.ted wrote:
>>>>>>
>>>>>> Is there a way of using a pure Ajax request to web2py authentication 
>>>>>> and create a session for a successfully logged in user?
>>>>>>
>>>>>> -- 
>>>>>> ............................................................
>>>>>> ...........................
>>>>>> Teddy Lubasi Nyambe
>>>>>> Opensource Zambia
>>>>>> Lusaka, ZAMBIA
>>>>>>
>>>>>> Cell: +260 97 7760473
>>>>>> website: http://www.opensource.org.zm
>>>>>>
>>>>>> ~/
>>>>>> Human Knowledge belongs to the world! - AntiTrust
>>>>>>
>>>>>> Man is a tool-using animal. Without tools he is nothing, with tools 
>>>>>> he is all - Thomas Carlyle 1795-1881
>>>>>>
>>>>>> /~ 
>>>>>>
>>>>>  -- 
>>>>  
>>>> --- 
>>>> 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] <javascript:>.
>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>  
>>>>  
>>>>
>>>  

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.

Reply via email to