Sessions and Activities and Places

78 views
Skip to first unread message

Mike Dee

unread,
Nov 13, 2011, 1:43:09 AM11/13/11
to Google Web Toolkit
What is a good way to have a GWT app redirect to a login screen when a
session expires? I've just hooked up a login page and a logout button
at an Activities and Places app. I basically handle this through the
event bus with login and logout events (haven't hooked up a session
time out yet).

The events work nicely. After logging in, the main place appears in
the app. When logging on, the login place appears. Very nice.

However, nothing prevents a user from accessing a place within the app
- either by bookmarking or using the back button after logging out.
I've experimented with a few things, but don't like any of them. For
example, in the AppActivityMapper if the user is not logged in, it
goes to the login place regardless of the requested place. I don't
like this because the URL still shows the requested place.

It looks like a central place to handle this is in
PlaceController.goTo(). While looking at the source, it appears that
changing places is handled via the event bus.

String warning = maybeGoTo(newPlace);
if (warning == null || delegate.confirm(warning)) {
where = newPlace;
eventBus.fireEvent(new PlaceChangeEvent(newPlace));

Has anyone tried overriding this to handle loggin/logout?
Message has been deleted
Message has been deleted

-sowdri-

unread,
Nov 14, 2011, 5:54:17 AM11/14/11
to google-we...@googlegroups.com
Have your tried moving login part to a separate GWT module, with a different url (consequently a separate host html) and let the container handle the session management?

Mike Dee

unread,
Nov 14, 2011, 5:10:30 PM11/14/11
to Google Web Toolkit
I'm sorry, I don't think I understand this. How would a separate GWT
module help? Wouldn't a separate module (with separate URL) produce a
separate session?

Mike Dee

unread,
Nov 15, 2011, 1:22:54 AM11/15/11
to Google Web Toolkit
I think I've found a good way to handle this. It really is pretty
easy.

I subclassed PlaceController and override it goTo() method. It looks
like this:

public void goTo( Place newPlace )
{
if( isLoggedIn )
super.goTo( newPlace );
else
super.goTo( new LoginPlace() );
}

It seems to work well. Handles pages that are bookmarked and the back
button.
Reply all
Reply to author
Forward
0 new messages