Skip to content

Commit

Permalink
redirect user to requested url after login via oauth
Browse files Browse the repository at this point in the history
  • Loading branch information
DanCech committed Feb 9, 2017
1 parent c7febca commit b22881c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/api/login_oauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"io/ioutil"
"log"
"net/http"
"net/url"

"golang.org/x/net/context"
"golang.org/x/oauth2"
Expand Down Expand Up @@ -177,5 +178,11 @@ func OAuthLogin(ctx *middleware.Context) {

metrics.M_Api_Login_OAuth.Inc(1)

if redirectTo, _ := url.QueryUnescape(ctx.GetCookie("redirect_to")); len(redirectTo) > 0 {
ctx.SetCookie("redirect_to", "", -1, setting.AppSubUrl+"/")
ctx.Redirect(redirectTo)
return
}

ctx.Redirect(setting.AppSubUrl + "/")
}

0 comments on commit b22881c

Please sign in to comment.