This commit is contained in:
Liang Ding 2014-11-17 11:20:35 +08:00
parent e06197db4c
commit 399a68e413
1 changed files with 45 additions and 10 deletions

View File

@ -71,7 +71,39 @@ func PreferenceHandler(w http.ResponseWriter, r *http.Request) {
// non-GET request as save request
succ := true
data := map[string]interface{}{"succ": &succ}
defer util.RetJSON(w, r, data)
args := struct {
FontFamily string
FontSize string
EditorFontFamily string
EditorFontSize string
EditorLineHeight string
GoFmt string
Workspace string
Username string
Password string
}{}
if err := json.NewDecoder(r.Body).Decode(&args); err != nil {
glog.Error(err)
succ = false
return
}
user.FontFamily = args.FontFamily
user.FontSize = args.FontSize
user.Editor.FontFamily = args.EditorFontFamily
user.Editor.FontSize = args.EditorFontSize
user.Editor.LineHeight = args.EditorLineHeight
user.GoFormat = args.GoFmt
user.Workspace = args.Workspace
user.Password = args.Password
succ = conf.Save()
}
// LoginHandler handles request of user login.
@ -98,7 +130,7 @@ func LoginHandler(w http.ResponseWriter, r *http.Request) {
// non-GET request as login request
succ := false
succ := true
data := map[string]interface{}{"succ": &succ}
defer util.RetJSON(w, r, data)
@ -109,14 +141,17 @@ func LoginHandler(w http.ResponseWriter, r *http.Request) {
if err := json.NewDecoder(r.Body).Decode(&args); err != nil {
glog.Error(err)
succ = true
succ = false
return
}
succ = false
for _, user := range conf.Wide.Users {
if user.Name == args.Username && user.Password == args.Password {
succ = true
break
}
}