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
|
/** 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. */
|
* 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) {
|
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);
|
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) {
|
public PageActionBuilder newAction(final ActionDefinition definition) {
|
||||||
final PageActionBuilder newBuilder = new PageActionBuilder(this.pageService, this.originalPageContext);
|
final PageActionBuilder newBuilder = new PageActionBuilder(this.pageService, this.originalPageContext);
|
||||||
newBuilder.pageContext = originalPageContext.copy();
|
newBuilder.pageContext = this.originalPageContext.copy();
|
||||||
newBuilder.definition = definition;
|
newBuilder.definition = definition;
|
||||||
newBuilder.confirm = null;
|
newBuilder.confirm = null;
|
||||||
newBuilder.successMessage = null;
|
newBuilder.successMessage = null;
|
||||||
|
@ -431,16 +431,16 @@ public interface PageService {
|
||||||
|
|
||||||
public PageAction create() {
|
public PageAction create() {
|
||||||
return new PageAction(
|
return new PageAction(
|
||||||
definition,
|
this.definition,
|
||||||
confirm,
|
this.confirm,
|
||||||
successMessage,
|
this.successMessage,
|
||||||
selectionSupplier,
|
this.selectionSupplier,
|
||||||
noSelectionMessage,
|
this.noSelectionMessage,
|
||||||
pageContext,
|
this.pageContext,
|
||||||
exec,
|
this.exec,
|
||||||
fireActionEvent,
|
this.fireActionEvent,
|
||||||
ignoreMoveAwayFromEdit,
|
this.ignoreMoveAwayFromEdit,
|
||||||
switchAction);
|
this.switchAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PageActionBuilder publish() {
|
public PageActionBuilder publish() {
|
||||||
|
@ -448,7 +448,7 @@ public interface PageService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public PageActionBuilder publish(final boolean active) {
|
public PageActionBuilder publish(final boolean active) {
|
||||||
pageService.publishAction(create(), active);
|
this.pageService.publishAction(create(), active);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -145,19 +145,16 @@ public class DefaultPageLayout implements TemplateComposer {
|
||||||
logout.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, true, true));
|
logout.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, true, true));
|
||||||
logout.setData(RWT.CUSTOM_VARIANT, "header");
|
logout.setData(RWT.CUSTOM_VARIANT, "header");
|
||||||
logout.addListener(SWT.Selection, event -> {
|
logout.addListener(SWT.Selection, event -> {
|
||||||
this.pageService.logout(pageContext);
|
if (this.pageService.logout(pageContext)) {
|
||||||
// show successful logout message
|
// show successful logout message
|
||||||
final MessageBox logoutSuccess = new Message(
|
final MessageBox logoutSuccess = new Message(
|
||||||
pageContext.getShell(),
|
pageContext.getShell(),
|
||||||
this.polyglotPageService.getI18nSupport().getText("sebserver.logout"),
|
this.polyglotPageService.getI18nSupport().getText("sebserver.logout"),
|
||||||
this.polyglotPageService.getI18nSupport().getText("sebserver.logout.success.message"),
|
this.polyglotPageService.getI18nSupport().getText("sebserver.logout.success.message"),
|
||||||
SWT.ICON_INFORMATION,
|
SWT.ICON_INFORMATION,
|
||||||
pageContext.getI18nSupport());
|
pageContext.getI18nSupport());
|
||||||
logoutSuccess.open(null);
|
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
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -366,7 +366,7 @@ public class PageServiceImpl implements PageService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void logout(final PageContext pageContext) {
|
public boolean logout(final PageContext pageContext) {
|
||||||
this.clearState();
|
this.clearState();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -374,14 +374,20 @@ public class PageServiceImpl implements PageService {
|
||||||
|
|
||||||
if (!logoutSuccessful) {
|
if (!logoutSuccessful) {
|
||||||
log.warn("Failed to logout. See log-files for more information");
|
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) {
|
} catch (final Exception e) {
|
||||||
log.info("Cleanup logout failed: {}", e.getMessage());
|
log.info("Cleanup logout failed: {}", e.getMessage(), e);
|
||||||
} finally {
|
pageContext.forwardToMainPage();
|
||||||
pageContext.forwardToLoginPage();
|
pageContext.notifyError(new LocTextKey("sebserver.error.logout"), e);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pageContext.forwardToLoginPage();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue