Edgewall Software
Modify

Opened 18 years ago

Closed 17 years ago

Last modified 17 years ago

#3808 closed enhancement (fixed)

redirecting to a custom page after logout

Reported by: anonymous Owned by: Christian Boos
Priority: low Milestone: 0.11
Component: general Version: 0.10.3
Severity: normal Keywords: custom logout navigation
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description (last modified by Christian Boos)

i would like to redirect my users to a custom page after logout as of now when a user logs out the page on which the user clicks the logout link is reloaded

Attachments (0)

Change History (16)

comment:1 by eric@…, 18 years ago

Keywords: custom logout added
Owner: changed from Jonas Borgström to anonymous
Priority: normallow
Version: 0.9.60.10.3

to redirict to a special url after logout and to prevent ugly logout errormessages change web/auth.py

 def _do_logout(self, req):
        """Log the user out.

        Simply deletes the corresponding record from the auth_cookie table.
        """
        if req.authname == 'anonymous':
            # Not logged in
            return

        # While deleting this cookie we also take the opportunity to delete
        # cookies older than 10 days
        db = self.env.get_db_cnx()
        cursor = db.cursor()
        cursor.execute("DELETE FROM auth_cookie WHERE name=%s OR time < %s",
                       (req.authname, int(time.time()) - 86400 * 10))
        db.commit()
<<<<<<<<<<<<<<<<<<<<<<<<<<< add this line >>>>>>>>>>>>>>>>>>>>>
        req.redirect( "/" ) #  put your logout url here 
<<<<<<<<<<<<<<<<<<<<<<<<<<< add end >>>>>>>>>>>>>>>>>>>>>>>>>>>
        self._expire_cookie(req)

or hope that someone will add a better configfile driven solution

comment:2 by Christian Boos, 18 years ago

Keywords: navigation added
Milestone: 0.11
Summary: redirecting to a cutom page after logoutredirecting to a custom page after logout

This could be part of the changes for making the navigation more easily customizable.

in reply to:  2 comment:3 by Emmanuel Blot, 18 years ago

Replying to cboos:

This could be part of the changes for making the navigation more easily customizable.

I do not remember the ticket reference, but it has been decided not to allow customization of wiki page names for "special" pages (WikiStart, RecentChanges, …).
I think that this decision should be applied for this enhancement as well: Trac could redirect to a predefined page name, but this page name could be "hardcoded".

comment:4 by Christian Boos, 18 years ago

Description: modified (diff)
Milestone: 0.11
Resolution: duplicate
Status: newclosed

You're referring to #4422 I believe. The difference here is that the logout link is in the general Trac navigation (metanav in this case), so we can't assume that the Wiki component will always be available. We therefore can't redirect to "LogOut" or something. But it should be possible to do this with a simple configuration setting, if wanted.

The idea of being able to configure the default location of the navigation entries is a follow-up of the "Discussing two changesets" trac-dev thread. So I'd like to come up with a consistent solution, and I even found a pre-existing ticket for that, see #2060.

in reply to:  4 comment:5 by Emmanuel Blot, 18 years ago

Replying to cboos:

You're referring to #4422 I believe. The difference here is that the logout link is in the general Trac navigation (metanav in this case), so we can't assume that the Wiki component will always be available.

Oops, you're right, I forgot to consider this important point.

in reply to:  4 comment:6 by Christian Boos, 18 years ago

Milestone: 0.11
Resolution: duplicate
Status: closedreopened

Replying to comment:4:

…I'd like to come up with a consistent solution, and I even found a pre-existing ticket for that, see #2060.

But #2060 as such (r5251) can't be used to alter the target of the redirect after the logout. We need a special case here.

comment:7 by Christian Boos, 18 years ago

Resolution: fixed
Status: reopenedclosed

Feature implemented in r5253.

comment:8 by Christian Boos, 17 years ago

Resolution: fixed
Status: closedreopened

comment:9 by Christian Boos, 17 years ago

Owner: changed from anonymous to Christian Boos
Status: reopenednew

Fixing owner.

comment:10 by Christian Boos, 17 years ago

Resolution: fixed
Status: newclosed

comment:11 by trac-ja@…, 17 years ago

Resolution: fixed
Status: closedreopened

I tested this feature with Environment url is on subdirectory, like http://hostname/projects/[PROJECTENV]/.

When I configured:

[metanav]
logout.redirect = wiki/Logout

redirect to http://hostname/wiki/Logout, instead of http://hostname/project/env/wiki/Logout.

Test variations:

config redirect to
wiki/Logout /wiki/Logout
/wiki/Logout /project/env/wiki/Logout
http://hostname/ http://hostname/
site/logout.html /site/logout.html
/site/logout.html /project/env/site/logout.html
But displays No handler matched request to /site/logout.html
/chrome/site/logout.html /project/env/chrome/site/logout.html

Maybe:

-            if custom_redirect.startswith('/'):
+            if not custom_redirect.startswith('/'):

in reply to:  11 ; comment:12 by Emmanuel Blot, 17 years ago

Replying to trac-ja@i-act.co.jp:

I tested this feature with Environment url is on subdirectory, like http://hostname/projects/[PROJECTENV]/.

What is the value of the base_url parameter in your trac.ini file?

in reply to:  12 comment:13 by trac-ja@…, 17 years ago

Replying to eblot:

Replying to trac-ja@i-act.co.jp:

I tested this feature with Environment url is on subdirectory, like http://hostname/projects/[PROJECTENV]/.

What is the value of the base_url parameter in your trac.ini file?

Sorry, base_url was not set.

Now, I set base_url to /projects/[PROJECTENV].

Variations:

config redirect to
wiki/Logout /projects/env/wiki/Logout
http://hostname/ http://hostname/
chrome/site/logout.html /projects/env/chrome/site/logout.html
/projects /projects/env/projects

On last example, I expect to redirect to /projects. I thought the config entry starts with / means url's root directory like [header_log] src and TracLinks.

Have I misunderstood this feature?

comment:14 by Christian Boos, 17 years ago

Resolution: fixed
Status: reopenedclosed

No, it seems you are right. Fixed in [6173].

comment:15 by Christian Boos, 17 years ago

Ah, wait, I only tested for 'wiki/Logout' and '/otherenv/wiki/Logout'. I need to handle the absolute URL case as well.

comment:16 by Christian Boos, 17 years ago

Ok, with [6174], this should now work for all your listed variations. Please confirm.

Extra points to be earned by updating TracNavigation ;-)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christian Boos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christian Boos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.