func addUser(email, pwd string) error { if email == "" || pwd == "" { return fmt.Errorf("please enter email and pwd") } user := auth.User{} user.Email = email user.Name = email user.Pwd = pwd user.CreatedTime = time.Now() user.UpdatedTime = user.CreatedTime err := auth.InsertUser(user) return err }
// add new authority func (self *UserResource) Post(ctx *rfweb.Context) { res := RespData{} user, err := getUserFromBody(ctx.R, true) if err != nil { res.Error = err.Error() } else { err = auth.InsertUser(*user) if err != nil { res.Error = err.Error() } else { res.Data = user res.Success = true // proxy.RemoveBackendConfCache() } } util.WriteJson(ctx.W, res) }