diff --git a/api/user.go b/api/user.go index 4840697..32d4ea0 100644 --- a/api/user.go +++ b/api/user.go @@ -59,6 +59,7 @@ func (a *UserAPI) CreateUser(ctx *gin.Context) { internal := toInternal(&user, []byte{}) if a.DB.GetUserByName(internal.Name) == nil { a.DB.CreateUser(internal) + ctx.JSON(200, toExternal(internal)) } else { ctx.AbortWithError(400, errors.New("username already exists")) } diff --git a/api/user_test.go b/api/user_test.go index 8bc332b..ceb49c6 100644 --- a/api/user_test.go +++ b/api/user_test.go @@ -136,6 +136,8 @@ func (s *UserSuite) Test_CreateUser() { s.a.CreateUser(s.ctx) s.db.AssertCalled(s.T(), "CreateUser", &model.User{Name: "tom", Pass: pwByte, Admin: true}) + + s.expectJSON(`{"id":0, "name":"tom", "admin":true}`) } func (s *UserSuite) Test_CreateUser_NoPassword() {