fix(user): assign snowflake IDs on registration

The HTTP register path left ID at 0, so SQLite/GORM filled a
serial primary key. CreateUser now generates a snowflake ID when
none is set, matching admin create and OAuth signup.
This commit is contained in:
ryan
2026-09-02 18:41:37 +08:00
parent 05606dfb56
commit 353a5f9f75
2 changed files with 7 additions and 1 deletions
@@ -166,6 +166,8 @@ func TestUserLoginHTTPHandler(t *testing.T) {
IsActive: true,
}
require.NoError(t, user.CreateUser(context.Background(), plainUser))
require.NotZero(t, plainUser.ID)
require.Greater(t, plainUser.ID, uint64(10000), "user id must be snowflake, not sqlite autoincrement")
reqBodyPlain := `{"username":"plain_admin","password":"12345678"}`
reqPlain, _ := http.NewRequest(http.MethodPost, "/api/v1/user/login", bytes.NewBufferString(reqBodyPlain))