mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-24 08:57:03 -05:00
Add tx around user creation
This commit is contained in:
parent
edf7f61b83
commit
e44be72251
1 changed files with 11 additions and 1 deletions
|
@ -9,6 +9,7 @@ import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"code.gitea.io/gitea/models/db"
|
||||||
"code.gitea.io/gitea/models/forgefed"
|
"code.gitea.io/gitea/models/forgefed"
|
||||||
"code.gitea.io/gitea/modules/log"
|
"code.gitea.io/gitea/modules/log"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
|
@ -57,7 +58,13 @@ func CreateFederatedUserFromAP(ctx context.Context, person forgefed.ForgePerson,
|
||||||
IsRestricted: util.OptionalBoolFalse,
|
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 {
|
if err := CreateUser(ctx, &user, overwrite); err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
@ -72,5 +79,8 @@ func CreateFederatedUserFromAP(ctx context.Context, person forgefed.ForgePerson,
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Commit transaction
|
||||||
|
committer.Commit()
|
||||||
|
|
||||||
return &user, &federatedUser, nil
|
return &user, &federatedUser, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue