diff options
author | Unknown <joe2010xtmf@163.com> | 2014-03-13 03:39:18 -0400 |
---|---|---|
committer | Unknown <joe2010xtmf@163.com> | 2014-03-13 03:39:18 -0400 |
commit | 57bc2d1ca0bfc3ba90e6d85309dba39415c6db73 (patch) | |
tree | 8d452408dbc3f89ac3a0a393ad5eadd80370f167 /routers/user/setting.go | |
parent | adedd9181c07ed926bf5835623293df4fcc706d2 (diff) | |
download | gitea-57bc2d1ca0bfc3ba90e6d85309dba39415c6db73.tar.gz gitea-57bc2d1ca0bfc3ba90e6d85309dba39415c6db73.zip |
Add update user profile back end, add new gitignore and license, add template data to public profile page
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) } |