예제 #1
0
// Delete a user
func del_user(w http.ResponseWriter, r *http.Request, uu *user) {
	glog.Info("Del a user.")
	u := new(define.User)
	r.ParseForm()
	u.Id = r.FormValue("id")
	if err := store.Manager.DelUser(u.Id, uu.ID); err != nil {
		glog.Errorf("Del user in the web error:%v", err)
		badReaquest(w, `{"status":"fail"}`)
	} else {
		uu.isOK = true
		io.WriteString(w, `{"id":"`)
		io.WriteString(w, u.Id)
		io.WriteString(w, `"}`)
	}
}
예제 #2
0
// Add a new user
func add_user(w http.ResponseWriter, r *http.Request, uu *user) {
	glog.Info("Add a new user(Client)")
	u := new(define.User)
	r.ParseForm()
	u.Psw = r.FormValue("psw")
	u.Owner = uu.ID
	if err := store.Manager.AddUser(u); err != nil {
		badReaquest(w, `{"status":"fail"}`)
	} else {
		uu.isOK = true
		io.WriteString(w, `{"id":"`)
		io.WriteString(w, u.Id)
		io.WriteString(w, `"}`)
	}
}