Example #1
0
func Admin(d db.DB) API {
	return func(r *htr.Router) error {
		if err := db.SetupBuckets(d, admin.Buckets()); err != nil {
			return err
		}
		r.GET("/admin/valid", handleAdminValid(d))
		r.GET("/admin/create", handleAdminCreate(d))
		r.GET("/admin/delete", handleAdminDelete(d))
		return nil
	}
}
Example #2
0
func (s *AdminSuite) SetUpTest(c *gc.C) {
	d, err := t.NewDB(
		t.SetupBolt("test.db"),
		t.SetupBuckets(admin.Buckets()),
	)
	c.Assert(err, jc.ErrorIsNil)
	s.d = d

	s.admins = map[string]t.TestAdmin{
		"bob": {
			Email:  "*****@*****.**",
			Pwhash: "12345",
		},
		"larry": {
			Email:  "*****@*****.**",
			Pwhash: "54321",
		},
	}
}
Example #3
0
func AdminCLI(d db.DB) cli.Binding {
	return func(c *cli.CLI) error {
		if err := db.SetupBuckets(d, admin.Buckets()); err != nil {
			return err
		}

		return c.AddCommands(&cli.Command{
			Name:        "create",
			Description: "create a new admin",
			Aliases:     []string{"c", "admin", "new"},
			Fn:          cliCreate(c, d),
		}, &cli.Command{
			Name:        "delete",
			Description: "delete an admin by email",
			Aliases:     []string{"d", "kill"},
			Fn:          cliDelete(d),
		})
	}
}