mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Allow Gogs to run from a suburl behind a reverse proxy. e.g. http://mydomain.com/gogs/
Conflicts: modules/setting/setting.go Conflicts: templates/repo/release/list.tmpl templates/user/dashboard/dashboard.tmpl Conflicts: routers/repo/setting.go
This commit is contained in:
@@ -82,7 +82,7 @@ func SignIn(ctx *middleware.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
ctx.Redirect("/")
|
||||
ctx.Redirect(setting.AppRootSubUrl + "/")
|
||||
}
|
||||
|
||||
func SignInPost(ctx *middleware.Context, form auth.SignInForm) {
|
||||
@@ -140,7 +140,7 @@ func SignInPost(ctx *middleware.Context, form auth.SignInForm) {
|
||||
return
|
||||
}
|
||||
|
||||
ctx.Redirect("/")
|
||||
ctx.Redirect(setting.AppRootSubUrl + "/")
|
||||
}
|
||||
|
||||
func SignOut(ctx *middleware.Context) {
|
||||
@@ -151,7 +151,7 @@ func SignOut(ctx *middleware.Context) {
|
||||
ctx.Session.Delete("socialEmail")
|
||||
ctx.SetCookie(setting.CookieUserName, "", -1)
|
||||
ctx.SetCookie(setting.CookieRememberName, "", -1)
|
||||
ctx.Redirect("/")
|
||||
ctx.Redirect(setting.AppRootSubUrl + "/")
|
||||
}
|
||||
|
||||
func oauthSignUp(ctx *middleware.Context, sid int64) {
|
||||
@@ -288,7 +288,7 @@ func SignUpPost(ctx *middleware.Context, cpt *captcha.Captcha, form auth.Registe
|
||||
return
|
||||
}
|
||||
|
||||
ctx.Redirect("/user/login")
|
||||
ctx.Redirect(setting.AppRootSubUrl + "/user/login")
|
||||
}
|
||||
|
||||
func Activate(ctx *middleware.Context) {
|
||||
@@ -335,7 +335,7 @@ func Activate(ctx *middleware.Context) {
|
||||
|
||||
ctx.Session.Set("uid", user.Id)
|
||||
ctx.Session.Set("uname", user.Name)
|
||||
ctx.Redirect("/")
|
||||
ctx.Redirect(setting.AppRootSubUrl + "/")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -437,7 +437,7 @@ func ResetPasswdPost(ctx *middleware.Context) {
|
||||
}
|
||||
|
||||
log.Trace("User password reset: %s", u.Name)
|
||||
ctx.Redirect("/user/login")
|
||||
ctx.Redirect(setting.AppRootSubUrl + "/user/login")
|
||||
return
|
||||
}
|
||||
|
||||
|
@@ -13,6 +13,7 @@ import (
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -126,7 +127,7 @@ func Profile(ctx *middleware.Context) {
|
||||
uname := ctx.Params(":username")
|
||||
// Special handle for FireFox requests favicon.ico.
|
||||
if uname == "favicon.ico" {
|
||||
ctx.Redirect("/img/favicon.png")
|
||||
ctx.Redirect(setting.AppRootSubUrl + "/img/favicon.png")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -141,7 +142,7 @@ func Profile(ctx *middleware.Context) {
|
||||
}
|
||||
|
||||
if u.IsOrganization() {
|
||||
ctx.Redirect("/org/" + u.Name)
|
||||
ctx.Redirect(setting.AppRootSubUrl + "/org/" + u.Name)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -181,7 +182,7 @@ func Email2User(ctx *middleware.Context) {
|
||||
}
|
||||
return
|
||||
}
|
||||
ctx.Redirect("/user/" + u.Name)
|
||||
ctx.Redirect(setting.AppRootSubUrl + "/user/" + u.Name)
|
||||
}
|
||||
|
||||
const (
|
||||
|
@@ -14,6 +14,7 @@ import (
|
||||
"github.com/gogits/gogs/modules/base"
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -55,7 +56,7 @@ func SettingsPost(ctx *middleware.Context, form auth.UpdateProfileForm) {
|
||||
} else if err = models.ChangeUserName(ctx.User, form.UserName); err != nil {
|
||||
if err == models.ErrUserNameIllegal {
|
||||
ctx.Flash.Error(ctx.Tr("form.illegal_username"))
|
||||
ctx.Redirect("/user/settings")
|
||||
ctx.Redirect(setting.AppRootSubUrl + "/user/settings")
|
||||
return
|
||||
} else {
|
||||
ctx.Handle(500, "ChangeUserName", err)
|
||||
@@ -78,7 +79,7 @@ func SettingsPost(ctx *middleware.Context, form auth.UpdateProfileForm) {
|
||||
}
|
||||
log.Trace("User setting updated: %s", ctx.User.Name)
|
||||
ctx.Flash.Success(ctx.Tr("settings.update_profile_success"))
|
||||
ctx.Redirect("/user/settings")
|
||||
ctx.Redirect(setting.AppRootSubUrl + "/user/settings")
|
||||
}
|
||||
|
||||
func SettingsPassword(ctx *middleware.Context) {
|
||||
@@ -119,7 +120,7 @@ func SettingsPasswordPost(ctx *middleware.Context, form auth.ChangePasswordForm)
|
||||
ctx.Flash.Success(ctx.Tr("settings.change_password_success"))
|
||||
}
|
||||
|
||||
ctx.Redirect("/user/settings/password")
|
||||
ctx.Redirect(setting.AppRootSubUrl + "/user/settings/password")
|
||||
}
|
||||
|
||||
func SettingsSSHKeys(ctx *middleware.Context) {
|
||||
@@ -160,7 +161,7 @@ func SettingsSSHKeysPost(ctx *middleware.Context, form auth.AddSSHKeyForm) {
|
||||
ctx.Handle(500, "DeletePublicKey", err)
|
||||
} else {
|
||||
log.Trace("SSH key deleted: %s", ctx.User.Name)
|
||||
ctx.Redirect("/user/settings/ssh")
|
||||
ctx.Redirect(setting.AppRootSubUrl + "/user/settings/ssh")
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -177,7 +178,7 @@ func SettingsSSHKeysPost(ctx *middleware.Context, form auth.AddSSHKeyForm) {
|
||||
|
||||
if ok, err := models.CheckPublicKeyString(cleanContent); !ok {
|
||||
ctx.Flash.Error(ctx.Tr("form.invalid_ssh_key", err.Error()))
|
||||
ctx.Redirect("/user/settings/ssh")
|
||||
ctx.Redirect(setting.AppRootSubUrl + "/user/settings/ssh")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -196,7 +197,7 @@ func SettingsSSHKeysPost(ctx *middleware.Context, form auth.AddSSHKeyForm) {
|
||||
} else {
|
||||
log.Trace("SSH key added: %s", ctx.User.Name)
|
||||
ctx.Flash.Success(ctx.Tr("settings.add_key_success"))
|
||||
ctx.Redirect("/user/settings/ssh")
|
||||
ctx.Redirect(setting.AppRootSubUrl + "/user/settings/ssh")
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -217,7 +218,7 @@ func SettingsSocial(ctx *middleware.Context) {
|
||||
return
|
||||
}
|
||||
ctx.Flash.Success(ctx.Tr("settings.unbind_success"))
|
||||
ctx.Redirect("/user/settings/social")
|
||||
ctx.Redirect(setting.AppRootSubUrl + "/user/settings/social")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -248,13 +249,13 @@ func SettingsDelete(ctx *middleware.Context) {
|
||||
switch err {
|
||||
case models.ErrUserOwnRepos:
|
||||
ctx.Flash.Error(ctx.Tr("form.still_own_repo"))
|
||||
ctx.Redirect("/user/settings/delete")
|
||||
ctx.Redirect(setting.AppRootSubUrl + "/user/settings/delete")
|
||||
default:
|
||||
ctx.Handle(500, "DeleteUser", err)
|
||||
}
|
||||
} else {
|
||||
log.Trace("Account deleted: %s", ctx.User.Name)
|
||||
ctx.Redirect("/")
|
||||
ctx.Redirect(setting.AppRootSubUrl + "/")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@@ -22,7 +22,7 @@ import (
|
||||
func extractPath(next string) string {
|
||||
n, err := url.Parse(next)
|
||||
if err != nil {
|
||||
return "/"
|
||||
return setting.AppRootSubUrl + "/"
|
||||
}
|
||||
return n.Path
|
||||
}
|
||||
@@ -88,7 +88,7 @@ func SocialSignIn(ctx *middleware.Context) {
|
||||
return
|
||||
}
|
||||
case models.ErrOauth2NotAssociated:
|
||||
next = "/user/sign_up"
|
||||
next = setting.AppRootSubUrl + "/user/sign_up"
|
||||
default:
|
||||
ctx.Handle(500, "social.SocialSignIn(GetOauth2)", err)
|
||||
return
|
||||
|
Reference in New Issue
Block a user