#851: Edit Account does not take into consideration password rules
This commit is contained in:
parent
35c83f6026
commit
33894591a6
5 changed files with 15 additions and 16 deletions
|
@ -79,7 +79,7 @@ func checkVersion() {
|
||||||
// Check dependency version.
|
// Check dependency version.
|
||||||
checkers := []VerChecker{
|
checkers := []VerChecker{
|
||||||
{"github.com/Unknwon/macaron", macaron.Version, "0.5.1"},
|
{"github.com/Unknwon/macaron", macaron.Version, "0.5.1"},
|
||||||
{"github.com/macaron-contrib/binding", binding.Version, "0.0.5"},
|
{"github.com/macaron-contrib/binding", binding.Version, "0.0.6"},
|
||||||
{"github.com/macaron-contrib/cache", cache.Version, "0.0.7"},
|
{"github.com/macaron-contrib/cache", cache.Version, "0.0.7"},
|
||||||
{"github.com/macaron-contrib/csrf", csrf.Version, "0.0.3"},
|
{"github.com/macaron-contrib/csrf", csrf.Version, "0.0.3"},
|
||||||
{"github.com/macaron-contrib/i18n", i18n.Version, "0.0.5"},
|
{"github.com/macaron-contrib/i18n", i18n.Version, "0.0.5"},
|
||||||
|
|
2
gogs.go
2
gogs.go
|
@ -17,7 +17,7 @@ import (
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
const APP_VER = "0.5.16.0316 Beta"
|
const APP_VER = "0.5.16.0317 Beta"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||||
|
|
|
@ -11,15 +11,15 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type AdminEditUserForm struct {
|
type AdminEditUserForm struct {
|
||||||
Email string `form:"email" binding:"Required;Email;MaxSize(50)"`
|
Email string `binding:"Required;Email;MaxSize(50)"`
|
||||||
Passwd string `form:"password"`
|
Password string `binding:"OmitEmpty;MinSize(6);MaxSize(255)"`
|
||||||
Website string `form:"website" binding:"MaxSize(50)"`
|
Website string `binding:"MaxSize(50)"`
|
||||||
Location string `form:"location" binding:"MaxSize(50)"`
|
Location string `binding:"MaxSize(50)"`
|
||||||
Avatar string `form:"avatar" binding:"Required;Email;MaxSize(50)"`
|
Avatar string `binding:"Required;Email;MaxSize(50)"`
|
||||||
Active bool `form:"active"`
|
Active bool
|
||||||
Admin bool `form:"admin"`
|
Admin bool
|
||||||
AllowGitHook bool `form:"allow_git_hook"`
|
AllowGitHook bool
|
||||||
LoginType int `form:"login_type"`
|
LoginType int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *AdminEditUserForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
func (f *AdminEditUserForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
||||||
|
|
|
@ -168,6 +168,7 @@ func EditUserPost(ctx *middleware.Context, form auth.AdminEditUserForm) {
|
||||||
ctx.Handle(500, "GetUserById", err)
|
ctx.Handle(500, "GetUserById", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
ctx.Data["User"] = u
|
||||||
|
|
||||||
if ctx.HasError() {
|
if ctx.HasError() {
|
||||||
ctx.HTML(200, USER_EDIT)
|
ctx.HTML(200, USER_EDIT)
|
||||||
|
@ -175,8 +176,8 @@ func EditUserPost(ctx *middleware.Context, form auth.AdminEditUserForm) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: need password length check
|
// FIXME: need password length check
|
||||||
if len(form.Passwd) > 0 {
|
if len(form.Password) > 0 {
|
||||||
u.Passwd = form.Passwd
|
u.Passwd = form.Password
|
||||||
u.Salt = models.GetUserSalt()
|
u.Salt = models.GetUserSalt()
|
||||||
u.EncodePasswd()
|
u.EncodePasswd()
|
||||||
}
|
}
|
||||||
|
@ -193,8 +194,6 @@ func EditUserPost(ctx *middleware.Context, form auth.AdminEditUserForm) {
|
||||||
u.IsAdmin = form.Admin
|
u.IsAdmin = form.Admin
|
||||||
u.AllowGitHook = form.AllowGitHook
|
u.AllowGitHook = form.AllowGitHook
|
||||||
|
|
||||||
ctx.Data["User"] = u
|
|
||||||
|
|
||||||
if err := models.UpdateUser(u); err != nil {
|
if err := models.UpdateUser(u); err != nil {
|
||||||
if err == models.ErrEmailAlreadyUsed {
|
if err == models.ErrEmailAlreadyUsed {
|
||||||
ctx.Data["Err_Email"] = true
|
ctx.Data["Err_Email"] = true
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
0.5.16.0316 Beta
|
0.5.16.0317 Beta
|
Loading…
Reference in a new issue