@ -22,8 +22,9 @@ func Setting(form auth.UpdateProfileForm, r render.Render, data base.TmplData, r
data [ "PageIsUserSetting" ] = true
data [ "PageIsUserSetting" ] = true
user := auth . SignedInUser ( session )
user := auth . SignedInUser ( session )
if req . Method == "GET" {
data [ "Owner" ] = user
data [ "Owner" ] = user
if req . Method == "GET" {
r . HTML ( 200 , "user/setting" , data )
r . HTML ( 200 , "user/setting" , data )
return
return
}
}
@ -37,6 +38,7 @@ func Setting(form auth.UpdateProfileForm, r render.Render, data base.TmplData, r
user . Website = form . Website
user . Website = form . Website
user . Location = form . Location
user . Location = form . Location
user . Avatar = base . EncodeMd5 ( form . Avatar )
user . Avatar = base . EncodeMd5 ( form . Avatar )
user . AvatarEmail = form . Avatar
if err := models . UpdateUser ( user ) ; err != nil {
if err := models . UpdateUser ( user ) ; err != nil {
data [ "ErrorMsg" ] = err
data [ "ErrorMsg" ] = err
log . Error ( "setting.Setting: %v" , err )
log . Error ( "setting.Setting: %v" , err )
@ -44,23 +46,21 @@ func Setting(form auth.UpdateProfileForm, r render.Render, data base.TmplData, r
return
return
}
}
data [ "IsSuccess" ] = true
r . HTML ( 200 , "user/setting" , data )
r . HTML ( 200 , "user/setting" , data )
}
}
func SettingEmailPassword ( r render . Render , data base . TmplData , session sessions . Session , req * http . Request ) {
func SettingPassword ( form auth . UpdatePasswdForm , r render . Render , data base . TmplData , session sessions . Session , req * http . Request ) {
data [ "Title" ] = "Email & Password"
data [ "Title" ] = "Password"
data [ "PageIsUserSetting" ] = true
data [ "PageIsUserSetting" ] = true
data [ "IsPwdSuccess" ] = ( req . FormValue ( "password" ) == "true" )
r . HTML ( 200 , "user/email_password" , data )
if req . Method == "GET" {
}
r . HTML ( 200 , "user/password" , data )
return
func UpdatePasswd ( form auth . UpdatePasswdForm , r render . Render , data base . TmplData , req * http . Request , session sessions . Session ) {
}
data [ "Title" ] = "Setting"
data [ "PageIsUserSetting" ] = true
user := auth . SignedInUser ( session )
user := auth . SignedInUser ( session )
newUser := & models . User { Passwd : form . Old Passwd}
newUser := & models . User { Passwd : form . New Passwd}
if err := newUser . EncodePasswd ( ) ; err != nil {
if err := newUser . EncodePasswd ( ) ; err != nil {
data [ "ErrorMsg" ] = err
data [ "ErrorMsg" ] = err
log . Error ( "setting.UpdatePasswd: %v" , 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
user . Passwd = newUser . Passwd
if err := models . UpdateUser ( user ) ; err != nil {
if err := models . UpdateUser ( user ) ; err != nil {
data [ "ErrorMsg" ] = err
data [ "ErrorMsg" ] = err
log . Error ( "setting.Setting : %v" , err )
log . Error ( "setting.UpdatePasswd : %v" , err )
r . HTML ( 200 , "base/error" , data )
r . HTML ( 200 , "base/error" , data )
return
return
}
}
data [ "IsSuccess" ] = true
}
}
data [ "Owner" ] = user
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 ) {
func SettingSSHKeys ( form auth . AddSSHKeyForm , r render . Render , data base . TmplData , req * http . Request , session sessions . Session ) {