diff options
Diffstat (limited to 'routers/user/setting.go')
-rw-r--r-- | routers/user/setting.go | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/routers/user/setting.go b/routers/user/setting.go index 0669784be0..63e4d8cb7d 100644 --- a/routers/user/setting.go +++ b/routers/user/setting.go @@ -17,9 +17,31 @@ import ( "github.com/gogits/gogs/modules/log" ) -func Setting(r render.Render, data base.TmplData, session sessions.Session) { +func Setting(form auth.UpdateProfileForm, r render.Render, data base.TmplData, req *http.Request, session sessions.Session) { data["Title"] = "Setting" data["PageIsUserSetting"] = true + + user := auth.SignedInUser(session) + if req.Method == "GET" { + data["Owner"] = user + } + + if hasErr, ok := data["HasError"]; ok && hasErr.(bool) { + r.HTML(200, "user/setting", data) + return + } + + user.Email = form.Email + user.Website = form.Website + user.Location = form.Location + user.Avatar = base.EncodeMd5(form.Avatar) + if err := models.UpdateUser(user); err != nil { + data["ErrorMsg"] = err + log.Error("setting.Setting: %v", err) + r.HTML(200, "base/error", data) + return + } + r.HTML(200, "user/setting", data) } |