fixed logout error bug
This commit is contained in:
parent
af8cca8ab2
commit
baee52a69a
3 changed files with 33 additions and 30 deletions
|
@ -309,7 +309,7 @@ public interface PageService {
|
|||
|
||||
/** This triggers a logout on the current authorization context to logout the current user
|
||||
* and forward to the login page with showing a successful logout message to the user. */
|
||||
void logout(PageContext pageContext);
|
||||
boolean logout(PageContext pageContext);
|
||||
|
||||
default <T> T logoutOnError(final Exception t, final PageContext pageContext) {
|
||||
log.error("Unexpected, Current User related error.Automatically logout and cleanup current user session. ", t);
|
||||
|
@ -416,7 +416,7 @@ public interface PageService {
|
|||
|
||||
public PageActionBuilder newAction(final ActionDefinition definition) {
|
||||
final PageActionBuilder newBuilder = new PageActionBuilder(this.pageService, this.originalPageContext);
|
||||
newBuilder.pageContext = originalPageContext.copy();
|
||||
newBuilder.pageContext = this.originalPageContext.copy();
|
||||
newBuilder.definition = definition;
|
||||
newBuilder.confirm = null;
|
||||
newBuilder.successMessage = null;
|
||||
|
@ -431,16 +431,16 @@ public interface PageService {
|
|||
|
||||
public PageAction create() {
|
||||
return new PageAction(
|
||||
definition,
|
||||
confirm,
|
||||
successMessage,
|
||||
selectionSupplier,
|
||||
noSelectionMessage,
|
||||
pageContext,
|
||||
exec,
|
||||
fireActionEvent,
|
||||
ignoreMoveAwayFromEdit,
|
||||
switchAction);
|
||||
this.definition,
|
||||
this.confirm,
|
||||
this.successMessage,
|
||||
this.selectionSupplier,
|
||||
this.noSelectionMessage,
|
||||
this.pageContext,
|
||||
this.exec,
|
||||
this.fireActionEvent,
|
||||
this.ignoreMoveAwayFromEdit,
|
||||
this.switchAction);
|
||||
}
|
||||
|
||||
public PageActionBuilder publish() {
|
||||
|
@ -448,7 +448,7 @@ public interface PageService {
|
|||
}
|
||||
|
||||
public PageActionBuilder publish(final boolean active) {
|
||||
pageService.publishAction(create(), active);
|
||||
this.pageService.publishAction(create(), active);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -145,19 +145,16 @@ public class DefaultPageLayout implements TemplateComposer {
|
|||
logout.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, true, true));
|
||||
logout.setData(RWT.CUSTOM_VARIANT, "header");
|
||||
logout.addListener(SWT.Selection, event -> {
|
||||
this.pageService.logout(pageContext);
|
||||
// show successful logout message
|
||||
final MessageBox logoutSuccess = new Message(
|
||||
pageContext.getShell(),
|
||||
this.polyglotPageService.getI18nSupport().getText("sebserver.logout"),
|
||||
this.polyglotPageService.getI18nSupport().getText("sebserver.logout.success.message"),
|
||||
SWT.ICON_INFORMATION,
|
||||
pageContext.getI18nSupport());
|
||||
logoutSuccess.open(null);
|
||||
|
||||
// TODO Try to invalidate RWT's user session.
|
||||
// This seems to be more difficult then expected and just invalidate the HttpSession doesn't work
|
||||
// Try to send a redirect JSON to the client: https://bugs.eclipse.org/bugs/show_bug.cgi?id=388249
|
||||
if (this.pageService.logout(pageContext)) {
|
||||
// show successful logout message
|
||||
final MessageBox logoutSuccess = new Message(
|
||||
pageContext.getShell(),
|
||||
this.polyglotPageService.getI18nSupport().getText("sebserver.logout"),
|
||||
this.polyglotPageService.getI18nSupport().getText("sebserver.logout.success.message"),
|
||||
SWT.ICON_INFORMATION,
|
||||
pageContext.getI18nSupport());
|
||||
logoutSuccess.open(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -366,7 +366,7 @@ public class PageServiceImpl implements PageService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void logout(final PageContext pageContext) {
|
||||
public boolean logout(final PageContext pageContext) {
|
||||
this.clearState();
|
||||
|
||||
try {
|
||||
|
@ -374,14 +374,20 @@ public class PageServiceImpl implements PageService {
|
|||
|
||||
if (!logoutSuccessful) {
|
||||
log.warn("Failed to logout. See log-files for more information");
|
||||
pageContext.forwardToMainPage();
|
||||
pageContext.publishInfo(new LocTextKey("sebserver.error.logout"));
|
||||
return false;
|
||||
}
|
||||
|
||||
} catch (final Exception e) {
|
||||
log.info("Cleanup logout failed: {}", e.getMessage());
|
||||
} finally {
|
||||
pageContext.forwardToLoginPage();
|
||||
log.info("Cleanup logout failed: {}", e.getMessage(), e);
|
||||
pageContext.forwardToMainPage();
|
||||
pageContext.notifyError(new LocTextKey("sebserver.error.logout"), e);
|
||||
return false;
|
||||
}
|
||||
|
||||
pageContext.forwardToLoginPage();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue