Ejemplo n.º 1
0
func Auth(d db.DB) API {
	return func(r *htr.Router) error {
		err := db.SetupBuckets(d, auth.Buckets())
		if err != nil {
			return err
		}
		r.GET("/user/create", handleCreate(d))
		r.GET("/user/delete", handleDelete(d))
		r.GET("/user/valid", handleValid(d))
		r.GET("/user/login", handleLogin(d))
		r.GET("/user/logout", handleLogout(d))
		return nil
	}
}
Ejemplo n.º 2
0
func (s *AuthSuite) SetUpTest(c *gc.C) {
	d, err := t.NewTestingDB(
		t.SetupBolt("test.db"),
		t.SetupBuckets(auth.Buckets()),
	)
	c.Assert(err, gc.IsNil)
	s.d = d
	s.users = map[string]t.TestUser{
		"bob": {
			Email:  "*****@*****.**",
			Pwhash: "12345",
		},
		"larry": {
			Email:  "*****@*****.**",
			Pwhash: "54321",
		},
	}
	auth.SetTimeout(time.Duration(50) * time.Millisecond)
}