PL-9451 Send redirect using VaadinResponse on logout if current UI is null

This commit is contained in:
Yuriy Artamonov 2017-08-04 12:19:18 +04:00
parent 9764b16ce2
commit fe533b6467

View File

@ -27,10 +27,7 @@ import com.haulmont.cuba.security.global.LoginException;
import com.haulmont.cuba.security.global.UserSession;
import com.haulmont.cuba.web.app.loginwindow.AppLoginWindow;
import com.haulmont.cuba.web.auth.ExternallyAuthenticatedConnection;
import com.vaadin.server.VaadinService;
import com.vaadin.server.VaadinSession;
import com.vaadin.server.WrappedHttpSession;
import com.vaadin.server.WrappedSession;
import com.vaadin.server.*;
import com.vaadin.ui.UI;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -40,6 +37,7 @@ import org.springframework.stereotype.Component;
import javax.inject.Inject;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.Locale;
/**
@ -134,6 +132,14 @@ public class DefaultApp extends App implements ConnectionListener, UserSubstitut
if (currentUi != null) {
currentUi.setContent(null);
currentUi.getPage().setLocation(loggedOutUrl);
} else {
VaadinResponse response = VaadinService.getCurrentResponse();
try {
((VaadinServletResponse) response).getHttpServletResponse().
sendRedirect(loggedOutUrl);
} catch (IOException e) {
log.error("Error on send redirect to client", e);
}
}
VaadinSession vaadinSession = VaadinSession.getCurrent();