aboutsummaryrefslogtreecommitdiffstats
path: root/routers/user
diff options
context:
space:
mode:
authorMartin van Beurden <chadoe@gmail.com>2014-09-14 19:35:22 +0200
committerMartin van Beurden <chadoe@gmail.com>2014-09-18 20:50:48 +0200
commit0055cbd3651ebde0f8b6cc70c9c44de56dc38830 (patch)
tree64a9ea617ba1f704139881c3960fa2425dad9018 /routers/user
parent4f74b4e6578be4251af65cd08daa37c884e431a0 (diff)
downloadgitea-0055cbd3651ebde0f8b6cc70c9c44de56dc38830.tar.gz
gitea-0055cbd3651ebde0f8b6cc70c9c44de56dc38830.zip
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
Diffstat (limited to 'routers/user')
-rw-r--r--routers/user/auth.go12
-rw-r--r--routers/user/home.go7
-rw-r--r--routers/user/setting.go19
-rw-r--r--routers/user/social.go4
4 files changed, 22 insertions, 20 deletions
diff --git a/routers/user/auth.go b/routers/user/auth.go
index e3d132166e..1dbc3300dd 100644
--- a/routers/user/auth.go
+++ b/routers/user/auth.go
@@ -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
}
diff --git a/routers/user/home.go b/routers/user/home.go
index 372f111aec..b411b8fc1f 100644
--- a/routers/user/home.go
+++ b/routers/user/home.go
@@ -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 (
diff --git a/routers/user/setting.go b/routers/user/setting.go
index 4e0e468f0e..a540f054f8 100644
--- a/routers/user/setting.go
+++ b/routers/user/setting.go
@@ -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
}
diff --git a/routers/user/social.go b/routers/user/social.go
index 07c6deed6d..fc2ea5fb49 100644
--- a/routers/user/social.go
+++ b/routers/user/social.go
@@ -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