Beispiel #1
0
func (s *UserSuite) testValidate(u t.TestUser, pause int, c *gc.C) error {
	<-time.NewTimer(timeout(pause)).C
	err := user.ValidLogin(s.d, u.Email, util.Key(u.LoginKey))
	if err != nil {
		return err
	}

	return nil
}
Beispiel #2
0
func (s *UserSuite) deleteTests(u t.TestUser, c *gc.C) error {
	if err := user.Delete(s.d, u.Email); err != nil {
		return err
	}

	err := user.ValidLogin(s.d, u.Email, util.Key(u.LoginKey))
	c.Assert(err, gc.ErrorMatches, fmt.Sprintf("could not get login for email %q not valid", u.Email))
	return nil
}
Beispiel #3
0
func handleUserValid(d db.DB) htr.Handle {
	return func(w http.ResponseWriter, r *http.Request, ps htr.Params) {
		if err := r.ParseForm(); err != nil {
			WriteResponse(w, newApiError(err.Error(), err))
			log.Printf("bad admin request: %#v", r)
			return
		}

		email := r.Form.Get("email")
		key := util.Key(r.Form.Get("key"))

		if err := user.ValidLogin(d, email, key); err != nil {
			WriteResponse(w, newApiError(err.Error(), err))
			log.Printf("error authenticating user %q, key %q: %s", email, key, err.Error())
			return
		}

		log.Printf("user %q validated", email)
		WriteResponse(w, &user.User{
			Email: email,
		})
	}
}