summaryrefslogtreecommitdiffstats
path: root/routers/user
diff options
context:
space:
mode:
Diffstat (limited to 'routers/user')
-rw-r--r--routers/user/setting.go24
-rw-r--r--routers/user/user.go45
2 files changed, 35 insertions, 34 deletions
diff --git a/routers/user/setting.go b/routers/user/setting.go
index 719e0c1919..66289b6e4d 100644
--- a/routers/user/setting.go
+++ b/routers/user/setting.go
@@ -24,13 +24,13 @@ func Setting(ctx *middleware.Context, form auth.UpdateProfileForm) {
ctx.Data["Owner"] = user
if ctx.Req.Method == "GET" {
- ctx.HTML(200, "user/setting", ctx.Data)
+ ctx.Render.HTML(200, "user/setting", ctx.Data)
return
}
// below is for POST requests
if hasErr, ok := ctx.Data["HasError"]; ok && hasErr.(bool) {
- ctx.HTML(200, "user/setting", ctx.Data)
+ ctx.Render.HTML(200, "user/setting", ctx.Data)
return
}
@@ -45,7 +45,7 @@ func Setting(ctx *middleware.Context, form auth.UpdateProfileForm) {
}
ctx.Data["IsSuccess"] = true
- ctx.HTML(200, "user/setting", ctx.Data)
+ ctx.Render.HTML(200, "user/setting", ctx.Data)
log.Trace("%s User setting updated: %s", ctx.Req.RequestURI, ctx.User.LowerName)
}
@@ -55,7 +55,7 @@ func SettingPassword(ctx *middleware.Context, form auth.UpdatePasswdForm) {
ctx.Data["IsUserPageSettingPasswd"] = true
if ctx.Req.Method == "GET" {
- ctx.HTML(200, "user/password", ctx.Data)
+ ctx.Render.HTML(200, "user/password", ctx.Data)
return
}
@@ -82,7 +82,7 @@ func SettingPassword(ctx *middleware.Context, form auth.UpdatePasswdForm) {
}
ctx.Data["Owner"] = user
- ctx.HTML(200, "user/password", ctx.Data)
+ ctx.Render.HTML(200, "user/password", ctx.Data)
log.Trace("%s User password updated: %s", ctx.Req.RequestURI, ctx.User.LowerName)
}
@@ -95,7 +95,7 @@ func SettingSSHKeys(ctx *middleware.Context, form auth.AddSSHKeyForm) {
if err != nil {
ctx.Data["ErrorMsg"] = err
log.Error("ssh.DelPublicKey: %v", err)
- ctx.JSON(200, map[string]interface{}{
+ ctx.Render.JSON(200, map[string]interface{}{
"ok": false,
"err": err.Error(),
})
@@ -109,13 +109,13 @@ func SettingSSHKeys(ctx *middleware.Context, form auth.AddSSHKeyForm) {
if err = models.DeletePublicKey(k); err != nil {
ctx.Data["ErrorMsg"] = err
log.Error("ssh.DelPublicKey: %v", err)
- ctx.JSON(200, map[string]interface{}{
+ ctx.Render.JSON(200, map[string]interface{}{
"ok": false,
"err": err.Error(),
})
} else {
log.Trace("%s User SSH key deleted: %s", ctx.Req.RequestURI, ctx.User.LowerName)
- ctx.JSON(200, map[string]interface{}{
+ ctx.Render.JSON(200, map[string]interface{}{
"ok": true,
})
}
@@ -125,7 +125,7 @@ func SettingSSHKeys(ctx *middleware.Context, form auth.AddSSHKeyForm) {
// Add new SSH key.
if ctx.Req.Method == "POST" {
if hasErr, ok := ctx.Data["HasError"]; ok && hasErr.(bool) {
- ctx.HTML(200, "user/publickey", ctx.Data)
+ ctx.Render.HTML(200, "user/publickey", ctx.Data)
return
}
@@ -157,7 +157,7 @@ func SettingSSHKeys(ctx *middleware.Context, form auth.AddSSHKeyForm) {
ctx.Data["PageIsUserSetting"] = true
ctx.Data["IsUserPageSettingSSH"] = true
ctx.Data["Keys"] = keys
- ctx.HTML(200, "user/publickey", ctx.Data)
+ ctx.Render.HTML(200, "user/publickey", ctx.Data)
}
func SettingNotification(ctx *middleware.Context) {
@@ -165,7 +165,7 @@ func SettingNotification(ctx *middleware.Context) {
ctx.Data["Title"] = "Notification"
ctx.Data["PageIsUserSetting"] = true
ctx.Data["IsUserPageSettingNotify"] = true
- ctx.HTML(200, "user/notification", ctx.Data)
+ ctx.Render.HTML(200, "user/notification", ctx.Data)
}
func SettingSecurity(ctx *middleware.Context) {
@@ -173,5 +173,5 @@ func SettingSecurity(ctx *middleware.Context) {
ctx.Data["Title"] = "Security"
ctx.Data["PageIsUserSetting"] = true
ctx.Data["IsUserPageSettingSecurity"] = true
- ctx.HTML(200, "user/security", ctx.Data)
+ ctx.Render.HTML(200, "user/security", ctx.Data)
}
diff --git a/routers/user/user.go b/routers/user/user.go
index 8c96607055..d702f2b956 100644
--- a/routers/user/user.go
+++ b/routers/user/user.go
@@ -9,6 +9,8 @@ import (
"strings"
"github.com/codegangsta/martini"
+ "github.com/martini-contrib/render"
+ "github.com/martini-contrib/sessions"
"github.com/gogits/gogs/models"
"github.com/gogits/gogs/modules/auth"
@@ -33,7 +35,7 @@ func Dashboard(ctx *middleware.Context) {
return
}
ctx.Data["Feeds"] = feeds
- ctx.HTML(200, "user/dashboard", ctx.Data)
+ ctx.Render.HTML(200, "user/dashboard", ctx.Data)
}
func Profile(ctx *middleware.Context, params martini.Params) {
@@ -68,21 +70,19 @@ func Profile(ctx *middleware.Context, params martini.Params) {
ctx.Data["Repos"] = repos
}
- ctx.Data["PageIsUserProfile"] = true // For navbar arrow.
-
- ctx.HTML(200, "user/profile", ctx.Data)
+ ctx.Render.HTML(200, "user/profile", ctx.Data)
}
func SignIn(ctx *middleware.Context, form auth.LogInForm) {
ctx.Data["Title"] = "Log In"
if ctx.Req.Method == "GET" {
- ctx.HTML(200, "user/signin", ctx.Data)
+ ctx.Render.HTML(200, "user/signin", ctx.Data)
return
}
if hasErr, ok := ctx.Data["HasError"]; ok && hasErr.(bool) {
- ctx.HTML(200, "user/signin", ctx.Data)
+ ctx.Render.HTML(200, "user/signin", ctx.Data)
return
}
@@ -99,13 +99,14 @@ func SignIn(ctx *middleware.Context, form auth.LogInForm) {
ctx.Session.Set("userId", user.Id)
ctx.Session.Set("userName", user.Name)
- ctx.Redirect("/")
+
+ ctx.Render.Redirect("/")
}
-func SignOut(ctx *middleware.Context) {
- ctx.Session.Delete("userId")
- ctx.Session.Delete("userName")
- ctx.Redirect("/")
+func SignOut(r render.Render, session sessions.Session) {
+ session.Delete("userId")
+ session.Delete("userName")
+ r.Redirect("/")
}
func SignUp(ctx *middleware.Context, form auth.RegisterForm) {
@@ -113,7 +114,7 @@ func SignUp(ctx *middleware.Context, form auth.RegisterForm) {
ctx.Data["PageIsSignUp"] = true
if ctx.Req.Method == "GET" {
- ctx.HTML(200, "user/signup", ctx.Data)
+ ctx.Render.HTML(200, "user/signup", ctx.Data)
return
}
@@ -126,7 +127,7 @@ func SignUp(ctx *middleware.Context, form auth.RegisterForm) {
}
if ctx.HasError() {
- ctx.HTML(200, "user/signup", ctx.Data)
+ ctx.Render.HTML(200, "user/signup", ctx.Data)
return
}
@@ -156,7 +157,7 @@ func SignUp(ctx *middleware.Context, form auth.RegisterForm) {
if base.Service.RegisterEmailConfirm {
auth.SendRegisterMail(u)
}
- ctx.Redirect("/user/login")
+ ctx.Render.Redirect("/user/login")
}
func Delete(ctx *middleware.Context) {
@@ -165,7 +166,7 @@ func Delete(ctx *middleware.Context) {
ctx.Data["IsUserPageSettingDelete"] = true
if ctx.Req.Method == "GET" {
- ctx.HTML(200, "user/delete", ctx.Data)
+ ctx.Render.HTML(200, "user/delete", ctx.Data)
return
}
@@ -185,12 +186,12 @@ func Delete(ctx *middleware.Context) {
return
}
} else {
- ctx.Redirect("/")
+ ctx.Render.Redirect("/")
return
}
}
- ctx.HTML(200, "user/delete", ctx.Data)
+ ctx.Render.HTML(200, "user/delete", ctx.Data)
}
const (
@@ -201,7 +202,7 @@ const (
func Feeds(ctx *middleware.Context, form auth.FeedsForm) {
actions, err := models.GetFeeds(form.UserId, form.Page*20, false)
if err != nil {
- ctx.JSON(500, err)
+ ctx.Render.JSON(500, err)
}
feeds := make([]string, len(actions))
@@ -209,19 +210,19 @@ func Feeds(ctx *middleware.Context, form auth.FeedsForm) {
feeds[i] = fmt.Sprintf(TPL_FEED, base.ActionIcon(actions[i].OpType),
base.TimeSince(actions[i].Created), base.ActionDesc(actions[i], ctx.User.AvatarLink()))
}
- ctx.JSON(200, &feeds)
+ ctx.Render.JSON(200, &feeds)
}
func Issues(ctx *middleware.Context) {
- ctx.HTML(200, "user/issues", ctx.Data)
+ ctx.Render.HTML(200, "user/issues", ctx.Data)
}
func Pulls(ctx *middleware.Context) {
- ctx.HTML(200, "user/pulls", ctx.Data)
+ ctx.Render.HTML(200, "user/pulls", ctx.Data)
}
func Stars(ctx *middleware.Context) {
- ctx.HTML(200, "user/stars", ctx.Data)
+ ctx.Render.HTML(200, "user/stars", ctx.Data)
}
func Activate(ctx *middleware.Context) {