Duplicate Javascript redirect after changing sesion ID
Added by Bram Ooms over 1 year ago
Hello,
I noticed that my widgets are rendered twice after logging in using the Wt Auth widget. This is caused by the WebRenderer which produces a duplicate javascript redirect after changing the session ID:
{if (window.location.replace) window.location.replace('/?_=/&wtd=H7iCbvQNBZBhSb6W');else window.location.href='/?_=/&wtd=H7iCbvQNBZBhSb6W';}
{if (window.location.replace) window.location.replace('/?_=/&wtd=H7iCbvQNBZBhSb6W');else window.location.href='/?_=/&wtd=H7iCbvQNBZBhSb6W';}
Duplicate redirect is caused by two calls to
collectJavaScriptUpdate()
which calls
WebRenderer::streamRedirectJS()
Can this be solved by checking if the session is is changed before calling collectJavaScriptUpdate the second time (in WebRenderer::collectJavaScript)?
For example changing on line 865 of WebRenderer.C:
...
if (visibleOnly_ && !session_.sessionIdChanged_) {
...
I also noticed that marking the session id unchanged in WebRenderer::collectJavaScriptUpdate does not work:
try {
if (session_.sessionIdChanged_) {
if (session_.hasSessionIdInUrl()) {
if (app->environment().ajax() &&
!app->environment().internalPathUsingFragments()) {
streamRedirectJS(out, app->url(app->internalPath()));
// better would be to use HTML5 history in this case but that would
// need some minor JavaScript reorganizations
} else {
streamRedirectJS(out, app->url(app->internalPath()));
}
out << '}';
return; // <-- will nit reach session_.sessionIdChanged_ = false; code
}
out << session_.app()->javaScriptClass()
<< "._p_.setSessionUrl("
<< WWebWidget::jsStringLiteral(sessionUrl())
<< ");";
session_.sessionIdChanged_ = false; // <-- session_.sessionIdChanged is already always false here!
}
Replies (1)
RE: Duplicate Javascript redirect after changing sesion ID - Added by Bram Ooms over 1 year ago
Duplicate javascript redirect results in duplicate GET request only in Google Chrome, not in Safari and Firefox.