[web2py] Re: How to use web2py auth using JavaScript+ajax?
I found an old thread: https://groups.google.com/forum/?fromgroups#!searchin/web2py/auth.login()$20from$20inside$20a$20component/web2py/Qg4AAePIlJw/tOTdGwtAj6EJ The discussion stopped at some point. On Friday, March 30, 2012 7:08:10 AM UTC-7, Anthony wrote: On Friday, March 30, 2012 2:22:42 AM UTC-4, thstart wrote: Thank you, could you please post an example? Perhaps someone else has a full working example. You just need a form on the page that gets posted via Ajax (see http://web2py.com/books/default/chapter/29/11#The-ajax-function), and then check the submitted credentials with auth.login_bare (see http://web2py.com/books/default/chapter/29/9#Manual-Authentication). Anthony
[web2py] Re: How to use web2py auth using JavaScript+ajax?
You may also want to look at this thread: https://groups.google.com/forum/?fromgroups#!topic/web2py/E5QxVWKxu6A On Friday, March 30, 2012 6:27:15 AM UTC+8, thstart wrote: I need to do a major rework in order to move client-side functionality to the browser and using Javascript to get more responsive client side experience with no refresh etc. That means web2py will give a rich server side functionality and all client work to be performed via JavaScript and Ajax. I made several tests and see this integration working just perfect. I successfully implemented auth with web2py. Now I need to make possible login/logout with just Javascript and Ajax snd calling web2py auth remotely. How to implement it so that I get the same functionality with sessions, etc? Assuming this is working, then how to retain the users' session state? Thanks in advance,
[web2py] Re: How to use web2py auth using JavaScript+ajax?
Here is another thread: https://groups.google.com/forum/?fromgroups#!topic/web2py/XaHiLQHQ9X0 Note that it will not be sufficient to just do login/logout with ajax. You may also wish to extend functionality to include registration and password retrieval. In addition, decorators will have to be handled as well. So ajaxification of auth is an involved process.
[web2py] Re: How to use web2py auth using JavaScript+ajax?
Thank you, could you please post an example? On Thursday, March 29, 2012 7:24:02 PM UTC-7, Anthony wrote: Now I need to make possible login/logout with just Javascript and Ajax snd calling web2py auth remotely. How to implement it so that I get the same functionality with sessions, etc? If you need to login with an Ajax request, try using auth.login_bare(). That will require you to handle the form creation and submission logic yourself. For Ajax logout, you can write your own function -- it just needs to add the logout event to the db via auth.log_event(auth.messages.logout_log, auth.user) and then set session.auth = None (the event logging is optional). Sessions should work as usual. Anthony
[web2py] Re: How to use web2py auth using JavaScript+ajax?
On Friday, March 30, 2012 2:22:42 AM UTC-4, thstart wrote: Thank you, could you please post an example? Perhaps someone else has a full working example. You just need a form on the page that gets posted via Ajax (see http://web2py.com/books/default/chapter/29/11#The-ajax-function), and then check the submitted credentials with auth.login_bare (see http://web2py.com/books/default/chapter/29/9#Manual-Authentication). Anthony
[web2py] Re: How to use web2py auth using JavaScript+ajax?
Now I need to make possible login/logout with just Javascript and Ajax snd calling web2py auth remotely. How to implement it so that I get the same functionality with sessions, etc? If you need to login with an Ajax request, try using auth.login_bare(). That will require you to handle the form creation and submission logic yourself. For Ajax logout, you can write your own function -- it just needs to add the logout event to the db via auth.log_event(auth.messages.logout_log, auth.user) and then set session.auth = None (the event logging is optional). Sessions should work as usual. Anthony