-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added auto refresh after session expires (#3125)
- Loading branch information
1 parent
7ec780e
commit 02982d2
Showing
4 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
roda-ui/roda-wui/src/main/java/org/roda/wui/client/main/ExpiredSessionDetector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package org.roda.wui.client.main; | ||
|
||
import com.google.gwt.user.client.rpc.AsyncCallback; | ||
import org.roda.core.data.v2.user.User; | ||
import org.roda.wui.client.common.UserLogin; | ||
import com.google.gwt.user.client.Timer; | ||
import org.roda.wui.client.management.RecoverLogin; | ||
import org.roda.wui.client.management.Register; | ||
import org.roda.wui.client.welcome.Welcome; | ||
import org.roda.wui.common.client.tools.HistoryUtils; | ||
|
||
/** | ||
* @author António Lindo <[email protected]> | ||
*/ | ||
public class ExpiredSessionDetector { | ||
private Timer timer; | ||
|
||
public ExpiredSessionDetector() { | ||
timer = new Timer() { | ||
@Override | ||
public void run() { | ||
checkSessionStatus(); | ||
} | ||
}; | ||
} | ||
|
||
public void setScheduleTime(int time) { | ||
timer.scheduleRepeating(time); | ||
} | ||
|
||
private boolean canGuestAccess() { | ||
String path = HistoryUtils.getCurrentHistoryPath().get(0); | ||
return path.equals(RecoverLogin.RESOLVER.getHistoryToken()) || path.equals(Login.RESOLVER.getHistoryToken()) | ||
|| path.equals(Theme.RESOLVER.getHistoryToken()) || path.equals(Register.RESOLVER.getHistoryToken()) | ||
|| path.equals(Welcome.RESOLVER.getHistoryToken()); | ||
} | ||
|
||
public void checkSessionStatus() { | ||
UserLogin.getInstance().getAuthenticatedUser(new AsyncCallback<User>() { | ||
@Override | ||
public void onFailure(Throwable caught) { | ||
UserLogin.getInstance().showSuggestLoginDialog(); | ||
} | ||
|
||
@Override | ||
public void onSuccess(User user) { | ||
if (user.isGuest()) { | ||
if (!canGuestAccess()) { | ||
HistoryUtils.newHistory(Welcome.RESOLVER); | ||
UserLogin.getInstance().showSuggestLoginDialog(); | ||
} | ||
} | ||
} | ||
}, true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters