[web2py] Re: REF: Question of Modifying the behaviour of the @auth.requires_login()
My reading of the source code says you are pretty much stuck with the behavior you see. The first thing the decorator does is check if the request is ajax and returns the message you are receiving. You could: - check auth.is_logged_in in your controller and take whatever action you wish if not true - write your own decorator that checks auth.is_logged_in On Tuesday, December 17, 2013 1:23:23 AM UTC-5, software.ted wrote: > > I am trying to create an application using web2py backend that is fully > AJAX. I amusing the jQuery/Javascript to create a client. Now am a bit > stuck on the customising the behavior @auth.requires_login() decorator. > > I have a jQuery request to an action with a @auth.requires_login() > decorator: > > Client > > function(){ > $('#div').load('{{"default","getPrice"}}'); > } > > > web2py control > > @auth.requires_login() > def getPrice(): > ... > ... > return locals() > > At the moment when i capture what is returned when not logged in is the > following text: > > NOT > AUTHORIZEDPlease login > to view this content. > > How can I return say forinstance true or false , logged in or logged > out...or redirect to an action that returns and invokes a jQuery login > window?? > > Thanx in advance > > > > > > -- > > ... > 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 > > /~ > -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: REF: Question of Modifying the behaviour of the @auth.requires_login()
http://www.artima.com/weblogs/viewpost.jsp?thread=240808 Terça-feira, 17 de Dezembro de 2013 6:23:23 UTC, software.ted escreveu: > > I am trying to create an application using web2py backend that is fully > AJAX. I amusing the jQuery/Javascript to create a client. Now am a bit > stuck on the customising the behavior @auth.requires_login() decorator. > > I have a jQuery request to an action with a @auth.requires_login() > decorator: > > Client > > function(){ > $('#div').load('{{"default","getPrice"}}'); > } > > > web2py control > > @auth.requires_login() > def getPrice(): > ... > ... > return locals() > > At the moment when i capture what is returned when not logged in is the > following text: > > NOT > AUTHORIZEDPlease login > to view this content. > > How can I return say forinstance true or false , logged in or logged > out...or redirect to an action that returns and invokes a jQuery login > window?? > > Thanx in advance > > > > > > -- > > ... > 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 > > /~ > -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: REF: Question of Modifying the behaviour of the @auth.requires_login()
You can probably start with the Auth.requires() decorator and modify as needed: https://github.com/web2py/web2py/blob/master/gluon/tools.py#L3201 Anthony On Thursday, December 19, 2013 9:07:10 AM UTC-5, Leonel Câmara wrote: > > http://www.artima.com/weblogs/viewpost.jsp?thread=240808 > > Terça-feira, 17 de Dezembro de 2013 6:23:23 UTC, software.ted escreveu: >> >> I am trying to create an application using web2py backend that is fully >> AJAX. I amusing the jQuery/Javascript to create a client. Now am a bit >> stuck on the customising the behavior @auth.requires_login() decorator. >> >> I have a jQuery request to an action with a @auth.requires_login() >> decorator: >> >> Client >> >> function(){ >> $('#div').load('{{"default","getPrice"}}'); >> } >> >> >> web2py control >> >> @auth.requires_login() >> def getPrice(): >> ... >> ... >> return locals() >> >> At the moment when i capture what is returned when not logged in is the >> following text: >> >> NOT >> AUTHORIZEDPlease login >> to view this content. >> >> How can I return say forinstance true or false , logged in or logged >> out...or redirect to an action that returns and invokes a jQuery login >> window?? >> >> Thanx in advance >> >> >> >> >> >> -- >> >> ... >> 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 >> >> /~ >> > -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: REF: Question of Modifying the behaviour of the @auth.requires_login()
How do you write decorators? On Wed, Dec 18, 2013 at 8:44 PM, Cliff Kachinske wrote: > My reading of the source code says you are pretty much stuck with the > behavior you see. The first thing the decorator does is check if the > request is ajax and returns the message you are receiving. > > You could: > - check auth.is_logged_in in your controller and take whatever action you > wish if not true > - write your own decorator that checks auth.is_logged_in > > > > On Tuesday, December 17, 2013 1:23:23 AM UTC-5, software.ted wrote: >> >> I am trying to create an application using web2py backend that is fully >> AJAX. I amusing the jQuery/Javascript to create a client. Now am a bit >> stuck on the customising the behavior @auth.requires_login() decorator. >> >> I have a jQuery request to an action with a @auth.requires_login() >> decorator: >> >> Client >> >> function(){ >> $('#div').load('{{"default","getPrice"}}'); >> } >> >> >> web2py control >> >> @auth.requires_login() >> def getPrice(): >> ... >> ... >> return locals() >> >> At the moment when i capture what is returned when not logged in is the >> following text: >> >> NOT >> AUTHORIZEDPlease > href="">login to view this content. >> >> How can I return say forinstance true or false , logged in or logged >> out...or redirect to an action that returns and invokes a jQuery login >> window?? >> >> Thanx in advance >> >> >> >> >> >> -- >> >> ... >> 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 >> >> /~ >> > -- > 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 web2py+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > -- ... 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 /~ -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [web2py] Re: REF: Question of Modifying the behaviour of the @auth.requires_login()
Thanks for the head start, will look at those options! On Thu, Dec 19, 2013 at 5:54 PM, Anthony wrote: > You can probably start with the Auth.requires() decorator and modify as > needed: https://github.com/web2py/web2py/blob/master/gluon/tools.py#L3201 > > Anthony > > > On Thursday, December 19, 2013 9:07:10 AM UTC-5, Leonel Câmara wrote: >> >> http://www.artima.com/weblogs/viewpost.jsp?thread=240808 >> >> Terça-feira, 17 de Dezembro de 2013 6:23:23 UTC, software.ted escreveu: >>> >>> I am trying to create an application using web2py backend that is fully >>> AJAX. I amusing the jQuery/Javascript to create a client. Now am a bit >>> stuck on the customising the behavior @auth.requires_login() decorator. >>> >>> I have a jQuery request to an action with a @auth.requires_login() >>> decorator: >>> >>> Client >>> >>> function(){ >>> $('#div').load('{{"default","getPrice"}}'); >>> } >>> >>> >>> web2py control >>> >>> @auth.requires_login() >>> def getPrice(): >>> ... >>> ... >>> return locals() >>> >>> At the moment when i capture what is returned when not logged in is the >>> following text: >>> >>> NOT >>> AUTHORIZEDPlease >> href="">login to view this content. >>> >>> How can I return say forinstance true or false , logged in or logged >>> out...or redirect to an action that returns and invokes a jQuery login >>> window?? >>> >>> Thanx in advance >>> >>> >>> >>> >>> >>> -- >>> >>> ... >>> 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 >>> >>> /~ >>> >> -- > 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 web2py+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > -- ... 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 /~ -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.