diff --git a/controllers/user.go b/controllers/user.go index e0cf87a..8566377 100644 --- a/controllers/user.go +++ b/controllers/user.go @@ -24,20 +24,37 @@ func (c *UserController) Prepare() { } func (c *UserController) Get() { + loginStr := c.getUserLogin() + u := user.GetUserByLogin(loginStr) + c.Data["user"] = u + c.TplName = "user.tpl" } func (c *UserController) Post() { pwd1 := c.Input().Get("password1") pwd2 := c.Input().Get("password2") + jid := c.Input().Get("jid") - if pwd1 == pwd2 { - login := c.GetSession(variables.SessionName) - switch lo := login.(type) { - case string: - user.ChangePassword(lo, pwd1) - } + loginStr := c.getUserLogin() + + user.ChangeJID(loginStr, jid) + + if pwd1 == pwd2 && pwd1 != "" { + user.ChangePassword(loginStr, pwd1) } c.Redirect(variables.UserRoute, 302) } + +func (c *UserController) getUserLogin() string { + ret := "" + + login := c.GetSession(variables.SessionName) + switch lo := login.(type) { + case string: + ret = lo + } + + return ret +} diff --git a/gofmt.sh b/gofmt.sh old mode 100644 new mode 100755 diff --git a/models/database/constantes.go b/models/database/constantes.go index 8091abc..93c9fca 100644 --- a/models/database/constantes.go +++ b/models/database/constantes.go @@ -5,9 +5,9 @@ import ( ) var ( - SQLITE = "sqlite" - MySQL = "mysql" - Alias = "default" + SQLITE = "sqlite" + MySQL = "mysql" + Alias = "default" DatabaseInstance = beego.AppConfig.String("database") UserDB = beego.AppConfig.String("mysqluser") @@ -17,9 +17,8 @@ var ( RowLimit = 4500 ) - func init() { - row_limit, err = beego.AppConfig.Int64("row_limit") + row_limit, err := beego.AppConfig.Int("row_limit") if err == nil { RowLimit = row_limit } diff --git a/models/user/user.go b/models/user/user.go index b1abd40..5850084 100644 --- a/models/user/user.go +++ b/models/user/user.go @@ -91,3 +91,14 @@ func ChangePassword(login, newPwd string) { o.Update(user) } } + +func ChangeJID(login, newJid string) { + o := orm.NewOrm() + o.Using(database.Alias) + + user := GetUserByLogin(login) + if o.Read(user) == nil { + user.JID = newJid + o.Update(user) + } +} diff --git a/static/css/user.css b/static/css/user.css index 3413a02..47b6388 100644 --- a/static/css/user.css +++ b/static/css/user.css @@ -38,3 +38,8 @@ body { border-top-left-radius: 0; border-top-right-radius: 0; } +.form-signin input[type="text"] { + margin-bottom: 30px; + border-top-left-radius: 0; + border-top-right-radius: 0; +} diff --git a/views/user.tpl b/views/user.tpl index bfd8726..ded04cf 100644 --- a/views/user.tpl +++ b/views/user.tpl @@ -7,11 +7,18 @@ {{define "body"}}

Chagement de mot de passe

- - + + - - + + + + +
@@ -21,9 +28,17 @@