mirror of
https://codeberg.org/forgejo/forgejo
synced 2024-11-22 01:44:24 +01:00
Add tx around user creation
This commit is contained in:
parent
edf7f61b83
commit
e44be72251
|
@ -9,6 +9,7 @@ import (
|
|||
"net/url"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/models/forgefed"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
|
@ -57,7 +58,13 @@ func CreateFederatedUserFromAP(ctx context.Context, person forgefed.ForgePerson,
|
|||
IsRestricted: util.OptionalBoolFalse,
|
||||
}
|
||||
|
||||
// TODO: Transaction around
|
||||
// Begin transaction
|
||||
ctx, committer, err := db.TxContext((ctx))
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
defer committer.Close()
|
||||
|
||||
if err := CreateUser(ctx, &user, overwrite); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
@ -72,5 +79,8 @@ func CreateFederatedUserFromAP(ctx context.Context, person forgefed.ForgePerson,
|
|||
return nil, nil, err
|
||||
}
|
||||
|
||||
// Commit transaction
|
||||
committer.Commit()
|
||||
|
||||
return &user, &federatedUser, nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue