fix: create temp user no longer sets ID to 0 for all users (#64149)

* fix: create temp user no longer sets ID to 0 for all users

The xorm tag added to the tempuser ID field caused xorm to create all temp users with ID 0. Removing that tag allows xorm to set the ID based on the database result instead. I also added a test which was failing before this.

Fixes #63995
This commit is contained in:
Kristin Laemmert 2023-03-03 10:50:54 -05:00 committed by GitHub
parent 2076282064
commit dbb72f2c6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -24,7 +24,7 @@ const (
// TempUser holds data for org invites and unconfirmed sign ups
type TempUser struct {
ID int64 `xorm:"id"`
ID int64 `xorm:"pk autoincr 'id'"`
OrgID int64 `xorm:"org_id"`
Version int
Email string

View File

@ -32,6 +32,13 @@ func TestIntegrationTempUserCommandsAndQueries(t *testing.T) {
require.Nil(t, err)
}
t.Run("Can create multiple temp users", func(t *testing.T) {
setup(t)
created, err := store.CreateTempUser(context.Background(), &cmd)
require.Nil(t, err)
require.Equal(t, int64(2), created.ID)
})
t.Run("Should be able to get temp users by org id", func(t *testing.T) {
setup(t)
query := tempuser.GetTempUsersQuery{OrgID: 2256, Status: tempuser.TmpUserInvitePending}