logout_bare()??

48 views
Skip to first unread message

Richard

unread,
Apr 6, 2016, 11:39:30 AM4/6/16
to web2py-developers
Hello,

I need to logout bare for testing of sqlhtml.py purpose...

I found this "auth.user = None" as a workaround though I am not sure if it the proper way to bare logout...

Any pointer would help...

Thanks

Richard

Anthony

unread,
Apr 6, 2016, 12:03:10 PM4/6/16
to web2py-developers
Why can't you use auth.logout(). If you are trying to avoid the redirect and callback, you can do auth.logout(next=None, onlogout=None).

Otherwise, I think either auth.user=None or session.auth=None should do it.

Anthony

Richard Vézina

unread,
Apr 6, 2016, 12:10:39 PM4/6/16
to web2py-d...@googlegroups.com
Try this and stay logged in...

Richard

--
-- mail from:GoogleGroups "web2py-developers" mailing list
make speech: web2py-d...@googlegroups.com
unsubscribe: web2py-develop...@googlegroups.com
details : http://groups.google.com/group/web2py-developers
the project: http://code.google.com/p/web2py/
official : http://www.web2py.com/
---
You received this message because you are subscribed to the Google Groups "web2py-developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py-develop...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Richard Vézina

unread,
Apr 6, 2016, 12:11:35 PM4/6/16
to web2py-d...@googlegroups.com
Try session.auth = None and didn't worked too I think... I will confirm...

Richard Vézina

unread,
Apr 6, 2016, 12:12:11 PM4/6/16
to web2py-d...@googlegroups.com
In [8]: session.auth = None

In [9]: auth.is_logged_in()
Out[9]: True


Richard Vézina

unread,
Apr 6, 2016, 12:13:52 PM4/6/16
to web2py-d...@googlegroups.com
Do you think logout_bare() is legitimate even if it just for testing purpose? It is convenient for shell work for power user as it is more intuitive too...

Richard

Massimo DiPierro

unread,
Apr 6, 2016, 12:26:22 PM4/6/16
to web2py-d...@googlegroups.com
auth.logout()  should work. Are you saying it does not?

Richard Vézina

unread,
Apr 6, 2016, 12:29:00 PM4/6/16
to web2py-d...@googlegroups.com
It's not!

At least in 2.13.4... I will try last stable...

Richard Vézina

unread,
Apr 6, 2016, 12:32:18 PM4/6/16
to web2py-d...@googlegroups.com
In [2]: auth.logout()
---------------------------------------------------------------------------
HTTP                                      Traceback (most recent call last)
/web2py/applications/sgddms/models/z_dict_creation.py in <module>()
----> 1 auth.logout()

/web2py/gluon/tools.pyc in logout(self, next, onlogout, log)
   3256         current.session.flash = self.messages.logged_out
   3257         if next is not None:
-> 3258             redirect(next)
   3259 
   3260     def register(self,

/web2py/gluon/http.pyc in redirect(location, how, client_side, headers)
    172             raise HTTP(how,
    173                        'You are being redirected <a href="%s">here</a>' % loc,
--> 174                        **headers)
    175     else:
    176         from gluon import current

HTTP: 303 SEE OTHER

In [3]: auth.logout(next=None, onlogout=None, log=None)

In [4]: auth.is_logged_in()
Out[4]: True

Anthony

unread,
Apr 6, 2016, 3:10:00 PM4/6/16
to web2py-developers
auth.logout() simply sets session.auth=None, so the actual logout doesn't take effect until the next request. If you are not using it in the context of HTTP requests, the auth.is_logged_in() test will still result in True, as that simply checks whether auth.user exists. So, if your goal is for auth.is_logged_in() to return True, then just set auth.user = None.

Anthony


On Wednesday, April 6, 2016 at 12:12:11 PM UTC-4, Richard wrote:
In [8]: session.auth = None

In [9]: auth.is_logged_in()
Out[9]: True


On Wed, Apr 6, 2016 at 12:11 PM, Richard Vézina <ml.richa...@gmail.com> wrote:
Try session.auth = None and didn't worked too I think... I will confirm...
On Wed, Apr 6, 2016 at 12:10 PM, Richard Vézina <ml.richa...@gmail.com> wrote:
Try this and stay logged in...

Richard
On Wed, Apr 6, 2016 at 12:03 PM, Anthony <abas...@gmail.com> wrote:
Why can't you use auth.logout(). If you are trying to avoid the redirect and callback, you can do auth.logout(next=None, onlogout=None).

Otherwise, I think either auth.user=None or session.auth=None should do it.

Anthony


On Wednesday, April 6, 2016 at 11:39:30 AM UTC-4, Richard wrote:
Hello,

I need to logout bare for testing of sqlhtml.py purpose...

I found this "auth.user = None" as a workaround though I am not sure if it the proper way to bare logout...

Any pointer would help...

Thanks

Richard

--
-- mail from:GoogleGroups "web2py-developers" mailing list

details : http://groups.google.com/group/web2py-developers
the project: http://code.google.com/p/web2py/
official : http://www.web2py.com/
---
You received this message because you are subscribed to the Google Groups "web2py-developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py-developers+unsubscribe@googlegroups.com.

Anthony

unread,
Apr 6, 2016, 3:11:11 PM4/6/16
to web2py-developers
Perhaps auth.logout() should also set auth.user=None in addition to clearing session.auth.

Anthony

Richard Vézina

unread,
Apr 6, 2016, 3:43:49 PM4/6/16
to web2py-d...@googlegroups.com
Consider also that auth.logout() fail if called as is... You need to do : auth.logout(next=None, onlogout=None, log=None) and even then you are not logged off from the shell since test fails if I am not using auth.user = None...

So, I suggest as you said that auth.logout() include auth.user = None and maybe :

def logout_bare():
    auth.logout(next=None, onlogout=None, log=None)

??

Richard

Anthony

details : http://groups.google.com/group/web2py-developers
the project: http://code.google.com/p/web2py/
official : http://www.web2py.com/
---
You received this message because you are subscribed to the Google Groups "web2py-developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py-develop...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
-- mail from:GoogleGroups "web2py-developers" mailing list

details : http://groups.google.com/group/web2py-developers
the project: http://code.google.com/p/web2py/
official : http://www.web2py.com/
---
You received this message because you are subscribed to the Google Groups "web2py-developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py-develop...@googlegroups.com.

Massimo DiPierro

unread,
Apr 6, 2016, 4:14:09 PM4/6/16
to web2py-d...@googlegroups.com
ok will do.

Richard Vézina

unread,
Apr 6, 2016, 10:48:09 PM4/6/16
to web2py-d...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages