|
|
|
@@ -6,12 +6,14 @@ |
|
|
|
package context |
|
|
|
|
|
|
|
import ( |
|
|
|
"encoding/base64" |
|
|
|
"net/http" |
|
|
|
"strings" |
|
|
|
|
|
|
|
"code.gitea.io/gitea/models" |
|
|
|
"code.gitea.io/gitea/modules/auth" |
|
|
|
"code.gitea.io/gitea/modules/log" |
|
|
|
"code.gitea.io/gitea/modules/setting" |
|
|
|
"encoding/base64" |
|
|
|
"net/http" |
|
|
|
|
|
|
|
"gitea.com/macaron/csrf" |
|
|
|
"gitea.com/macaron/macaron" |
|
|
|
@@ -94,7 +96,14 @@ func Toggle(options *ToggleOptions) macaron.Handler { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
ctx.SetCookie("redirect_to", setting.AppSubURL+ctx.Req.URL.RequestURI(), 0, setting.AppSubURL) |
|
|
|
tempUrl := ctx.Req.URL.RequestURI() |
|
|
|
|
|
|
|
if strings.Contains(tempUrl, "action/star?") || strings.Contains(tempUrl, "action/watch?") { |
|
|
|
redirectForStarAndWatch(ctx, tempUrl) |
|
|
|
|
|
|
|
} else { |
|
|
|
ctx.SetCookie("redirect_to", setting.AppSubURL+ctx.Req.URL.RequestURI(), 0, setting.AppSubURL) |
|
|
|
} |
|
|
|
ctx.Redirect(setting.AppSubURL + "/user/login") |
|
|
|
return |
|
|
|
} else if !ctx.User.IsActive && setting.Service.RegisterEmailConfirm { |
|
|
|
@@ -159,6 +168,17 @@ func Toggle(options *ToggleOptions) macaron.Handler { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
func redirectForStarAndWatch(ctx *Context, tempUrl string) { |
|
|
|
splits := strings.Split(tempUrl, "?") |
|
|
|
if len(splits) > 1 { |
|
|
|
redirectArguments := strings.Split(splits[1], "=") |
|
|
|
|
|
|
|
if len(redirectArguments) > 0 && redirectArguments[0] == "redirect_to" { |
|
|
|
ctx.SetCookie("redirect_to", setting.AppSubURL+strings.Replace(redirectArguments[1], "%2f", "/", -1), 0, setting.AppSubURL) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
func basicAuth(ctx *Context) bool { |
|
|
|
var siteAuth = base64.StdEncoding.EncodeToString([]byte(setting.CBAuthUser + ":" + setting.CBAuthPassword)) |
|
|
|
auth := ctx.Req.Header.Get("Authorization") |
|
|
|
|