Skip to content

Commit

Permalink
[JENKINS-36706] Handle session timeout better
Browse files Browse the repository at this point in the history
  • Loading branch information
recampbell committed Feb 4, 2017
1 parent bd9d822 commit 3d999a0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Expand Up @@ -42,6 +42,7 @@
import hudson.Extension;
import hudson.Util;
import hudson.model.Descriptor;
import hudson.model.Failure;
import hudson.model.User;
import hudson.security.SecurityRealm;
import hudson.util.HttpResponses;
Expand Down Expand Up @@ -243,7 +244,11 @@ private String buildOAuthRedirectUrl() {
* This is where the user comes back to at the end of the OpenID redirect ping-pong.
*/
public HttpResponse doFinishLogin(StaplerRequest request) throws IOException {
return OAuthSession.getCurrent().doFinishLogin(request);
if (OAuthSession.getCurrent() != null) {
return OAuthSession.getCurrent().doFinishLogin(request);
} else {
return new Failure("Your Jenkins session has expired. Please login again.");
}
}

@Extension
Expand Down
Expand Up @@ -84,6 +84,10 @@ public HttpResponse doCommenceLogin() throws IOException {
* When the identity provider is done with its thing, the user comes back here.
*/
public HttpResponse doFinishLogin(StaplerRequest request) throws IOException {
if (request.getParameter("state") == null) {
// user was not sent here by Google
return HttpResponses.redirectToContextRoot();
}
StringBuffer buf = request.getRequestURL();
if (request.getQueryString() != null) {
buf.append('?').append(request.getQueryString());
Expand Down

0 comments on commit 3d999a0

Please sign in to comment.