Merge remote-tracking branch 'origin/patch-1.0.2' into development

Conflicts:
	src/main/java/ch/ethz/seb/sebserver/gui/service/page/PageService.java
	src/main/java/ch/ethz/seb/sebserver/gui/service/page/impl/PageServiceImpl.java
This commit is contained in:
anhefti 2020-11-12 14:01:06 +01:00
commit bee3f7a059
No known key found for this signature in database
GPG key ID: E9AD9471B6BC114D
3 changed files with 34 additions and 31 deletions

View file

@ -346,7 +346,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);
@ -474,7 +474,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;
@ -489,17 +489,17 @@ public interface PageService {
public PageAction create() {
return new PageAction(
definition,
confirm,
successMessage,
selectionSupplier,
noSelectionMessage,
pageContext,
exec,
fireActionEvent,
ignoreMoveAwayFromEdit,
switchAction,
titleArgs);
this.definition,
this.confirm,
this.successMessage,
this.selectionSupplier,
this.noSelectionMessage,
this.pageContext,
this.exec,
this.fireActionEvent,
this.ignoreMoveAwayFromEdit,
this.switchAction,
this.titleArgs);
}
public PageActionBuilder publish() {
@ -507,7 +507,7 @@ public interface PageService {
}
public PageActionBuilder publish(final boolean active) {
pageService.publishAction(create(), active);
this.pageService.publishAction(create(), active);
return this;
}

View file

@ -145,7 +145,7 @@ 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);
if (this.pageService.logout(pageContext)) {
// show successful logout message
final MessageBox logoutSuccess = new Message(
pageContext.getShell(),
@ -154,10 +154,7 @@ public class DefaultPageLayout implements TemplateComposer {
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
}
});
}
}

View file

@ -384,7 +384,7 @@ public class PageServiceImpl implements PageService {
}
@Override
public void logout(final PageContext pageContext) {
public boolean logout(final PageContext pageContext) {
this.clearState();
try {
@ -392,14 +392,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