func (u *userReqPutBody) OK() *ae.Error { if len(u.FirstName) == 0 { return ae.Required("", "first_name") } else if len(u.LastName) == 0 { return ae.Required("", "last_name") } else if !validate.Url(u.ProfilePicURL) { return ae.InvalidInput("", "url") } else if u.MetricSystem != 1 && u.MetricSystem != 2 { return ae.InvalidInput("", "Metric System") } return nil }
func (r *userReqPostBody) OK() *ae.Error { if len(r.Email) == 0 && len(r.GoogleKey) == 0 { return ae.Required("", "(email and pass) or (google_key)") } else if len(r.Email) != 0 { if len(r.Password) == 0 { return ae.Required("", "password") } else if !validate.Email(r.Email) { return ae.InvalidInput("", "email") } else if !validate.Password(r.Password) { return ae.InvalidInput("Invalid Password", "password") } } return nil }
func EmailExists(w http.ResponseWriter, r *http.Request) { urlParams := context.Get(r, "params").(httprouter.Params) email := urlParams.ByName("email") if len(email) == 0 { reply.Err(w, ae.Required("", "email")) return } user := model.User{} user.Email = email exists, err := user.EmailExists() if err != nil { reply.Err(w, ae.DB("", err)) return } result := make(map[string]interface{}) result["exists"] = exists reply.OK(w, result) }
func (r *authorizePutBody) OK() *ae.Error { if len(r.RefreshToken) == 0 { return ae.Required("", "refresh_token") } return nil }