[Zope] acl_users

Duncan Booth duncan@rcp.co.uk
Thu, 12 Aug 1999 16:33:30 +0000


> Another one, how can we logout from the current session(if there's one in 
>  Zope) and relogin again as another user? I need this to do testing on  
> different type of user. I don't want to wait for it to timeoutto login  
> again as another user. Please help me . It's urgent. Thanks in advance.
> 
>  -- Paul Chung
> 

Create a DTML document called logout at the top of your Zope tree 
which raises an unauthorized error.
<dtml-if ExUser>
   <dtml-if "ExUser==_.str(AUTHENTICATED_USER)">
      <dtml-raise type="Unauthorized">
         You have been logged out.
      </dtml-raise>
   <dtml-else>
      <dtml-var "RESPONSE.redirect('index_html')">
   </dtml-if>
<dtml-else>
   <dtml-var "RESPONSE.redirect('logout?ExUser=%s' % 
AUTHENTICATED_USER)">
</dtml-if>

Now you can have a logout link or whatever at 
http://host/somepath/logout. The only catch is that once you hit it 
you *must* use a different userid as the current one will be rejected 
unconditionally. When you do enter a new userid you get redirected 
to the index_html at the current level. An empty string works as well 
instead of 'index_html' if you prefer.

-- 
Duncan Booth                                             duncan@dales.rmplc.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
http://dales.rmplc.co.uk/Duncan