Exemplo n.º 1
0
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
}
Exemplo n.º 2
0
// 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)
}