Project

General

Profile

Performing cleanup on logout

Added by Nathan Ridge about 11 years ago

Hello,

I have a simple question about Wt. I need to do some cleanup when a user logs out, and that cleanup needs to know the username of the user that is logging out. What is an appropriate place for this cleanup code?

It would seem most natural to do it in a slot for the Login object's changed() signal, but when that signal is emitted the user is already logged out, so I cannot obtain their username.

What I've seen other frameworks do in similar situations is emit two signals related to an event such as a logout: a signal just before the event happens, signalling that it's about to happen (in some frameworks, slots for this signal can even "veto" the event), and a signal just after the event, signalling that is has happened. Then code that relies on state just before the event (e.g. the username of the logged-in user) can go in a slot for the first signal.

I suppose I could keep track of the logged-in user's username myself by saving it in the changed() signal for a login, but I'm wondering if there's a nicer way to accomplish this.

Thanks,

Nate


Replies (1)

RE: Performing cleanup on logout - Added by Koen Deforche about 11 years ago

Hey Nate,

I guess we didn't think of this ... So I fear there is currently no better solution. We should add more events to the Login object, e.g. an event that is raised when a user logs out which is then triggered before calling the more general changed() signal.

Regards,

koen

    (1-1/1)