Fix duplicate entry error when add team member (#19702)
This commit is contained in:
parent
b135313c47
commit
77e9346342
|
@ -496,6 +496,12 @@ func AddTeamMember(team *organization.Team, userID int64) error {
|
||||||
}
|
}
|
||||||
defer committer.Close()
|
defer committer.Close()
|
||||||
|
|
||||||
|
// check in transaction
|
||||||
|
isAlreadyMember, err = organization.IsTeamMember(ctx, team.OrgID, team.ID, userID)
|
||||||
|
if err != nil || isAlreadyMember {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
sess := db.GetEngine(ctx)
|
sess := db.GetEngine(ctx)
|
||||||
|
|
||||||
if err := db.Insert(ctx, &organization.TeamUser{
|
if err := db.Insert(ctx, &organization.TeamUser{
|
||||||
|
|
|
@ -594,6 +594,12 @@ func AddOrgUser(orgID, uid int64) error {
|
||||||
}
|
}
|
||||||
defer committer.Close()
|
defer committer.Close()
|
||||||
|
|
||||||
|
// check in transaction
|
||||||
|
isAlreadyMember, err = IsOrganizationMember(ctx, orgID, uid)
|
||||||
|
if err != nil || isAlreadyMember {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
ou := &OrgUser{
|
ou := &OrgUser{
|
||||||
UID: uid,
|
UID: uid,
|
||||||
OrgID: orgID,
|
OrgID: orgID,
|
||||||
|
|
Loading…
Reference in New Issue