aboutsummaryrefslogtreecommitdiffstats
path: root/models/organization
diff options
context:
space:
mode:
authorzuzuviewer <750938164@qq.com>2022-05-14 21:30:19 +0800
committerGitHub <noreply@github.com>2022-05-14 16:30:19 +0300
commit77e9346342ccea20157412820b08204f122f262f (patch)
tree373e172eaf315cbc57168194fece3e9886678ae7 /models/organization
parentb135313c478a241ce994d19e685f2a39d066fb92 (diff)
downloadgitea-77e9346342ccea20157412820b08204f122f262f.tar.gz
gitea-77e9346342ccea20157412820b08204f122f262f.zip
Fix duplicate entry error when add team member (#19702)
Diffstat (limited to 'models/organization')
-rw-r--r--models/organization/org.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/models/organization/org.go b/models/organization/org.go
index 3761335922..43d96793b1 100644
--- a/models/organization/org.go
+++ b/models/organization/org.go
@@ -594,6 +594,12 @@ func AddOrgUser(orgID, uid int64) error {
}
defer committer.Close()
+ // check in transaction
+ isAlreadyMember, err = IsOrganizationMember(ctx, orgID, uid)
+ if err != nil || isAlreadyMember {
+ return err
+ }
+
ou := &OrgUser{
UID: uid,
OrgID: orgID,