diff --git a/gogs.go b/gogs.go index 96c0f84f2b..b276490280 100644 --- a/gogs.go +++ b/gogs.go @@ -20,7 +20,7 @@ import ( // Test that go1.1 tag above is included in builds. main.go refers to this definition. const go11tag = true -const APP_VER = "0.0.7.0313" +const APP_VER = "0.0.7.0314" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/models/user.go b/models/user.go index 06db7d8ba2..8f7a37cba9 100644 --- a/models/user.go +++ b/models/user.go @@ -49,6 +49,7 @@ type User struct { NumStars int NumRepos int Avatar string `xorm:"varchar(2048) not null"` + AvatarEmail string `xorm:"not null"` Location string Website string Created time.Time `xorm:"created"` @@ -106,6 +107,7 @@ func RegisterUser(user *User) (err error) { user.LowerName = strings.ToLower(user.Name) user.Avatar = base.EncodeMd5(user.Email) + user.AvatarEmail = user.Email if err = user.EncodePasswd(); err != nil { return err } diff --git a/modules/auth/user.go b/modules/auth/user.go index 6bc7130626..ef595c6000 100644 --- a/modules/auth/user.go +++ b/modules/auth/user.go @@ -96,7 +96,7 @@ type FeedsForm struct { type UpdateProfileForm struct { Email string `form:"email" binding:"Required;Email;MaxSize(50)"` - Website string `form:"website" binding:"AlphaDash;MaxSize(50)"` + Website string `form:"website" binding:"MaxSize(50)"` Location string `form:"location" binding:"MaxSize(50)"` Avatar string `form:"avatar" binding:"Required;Email;MaxSize(50)"` } diff --git a/routers/user/setting.go b/routers/user/setting.go index cf11095bea..08879ae4a7 100644 --- a/routers/user/setting.go +++ b/routers/user/setting.go @@ -22,8 +22,9 @@ func Setting(form auth.UpdateProfileForm, r render.Render, data base.TmplData, r data["PageIsUserSetting"] = true user := auth.SignedInUser(session) + data["Owner"] = user + if req.Method == "GET" { - data["Owner"] = user r.HTML(200, "user/setting", data) return } @@ -37,6 +38,7 @@ func Setting(form auth.UpdateProfileForm, r render.Render, data base.TmplData, r user.Website = form.Website user.Location = form.Location user.Avatar = base.EncodeMd5(form.Avatar) + user.AvatarEmail = form.Avatar if err := models.UpdateUser(user); err != nil { data["ErrorMsg"] = err log.Error("setting.Setting: %v", err) @@ -44,23 +46,21 @@ func Setting(form auth.UpdateProfileForm, r render.Render, data base.TmplData, r return } + data["IsSuccess"] = true r.HTML(200, "user/setting", data) } -func SettingEmailPassword(r render.Render, data base.TmplData, session sessions.Session, req *http.Request) { - data["Title"] = "Email & Password" +func SettingPassword(form auth.UpdatePasswdForm, r render.Render, data base.TmplData, session sessions.Session, req *http.Request) { + data["Title"] = "Password" data["PageIsUserSetting"] = true - data["IsPwdSuccess"] = (req.FormValue("password") == "true") - r.HTML(200, "user/email_password", data) -} - -func UpdatePasswd(form auth.UpdatePasswdForm, r render.Render, data base.TmplData, req *http.Request, session sessions.Session) { - data["Title"] = "Setting" - data["PageIsUserSetting"] = true + if req.Method == "GET" { + r.HTML(200, "user/password", data) + return + } user := auth.SignedInUser(session) - newUser := &models.User{Passwd: form.OldPasswd} + newUser := &models.User{Passwd: form.NewPasswd} if err := newUser.EncodePasswd(); err != nil { data["ErrorMsg"] = err log.Error("setting.UpdatePasswd: %v", err) @@ -78,14 +78,15 @@ func UpdatePasswd(form auth.UpdatePasswdForm, r render.Render, data base.TmplDat user.Passwd = newUser.Passwd if err := models.UpdateUser(user); err != nil { data["ErrorMsg"] = err - log.Error("setting.Setting: %v", err) + log.Error("setting.UpdatePasswd: %v", err) r.HTML(200, "base/error", data) return } + data["IsSuccess"] = true } data["Owner"] = user - r.HTML(200, "user/setting", data) + r.HTML(200, "user/password", data) } func SettingSSHKeys(form auth.AddSSHKeyForm, r render.Render, data base.TmplData, req *http.Request, session sessions.Session) { diff --git a/templates/user/delete.tmpl b/templates/user/delete.tmpl index 37259f61e5..904201772e 100644 --- a/templates/user/delete.tmpl +++ b/templates/user/delete.tmpl @@ -5,7 +5,7 @@

Account Setting