feat(invite): handling of existing org user case when inviting, #2353

This commit is contained in:
Torkel Ödegaard
2015-07-21 12:18:11 +02:00
parent ab54971763
commit 6d6af09296
4 changed files with 33 additions and 14 deletions
+6
View File
@@ -19,6 +19,12 @@ func init() {
func AddOrgUser(cmd *m.AddOrgUserCommand) error {
return inTransaction(func(sess *xorm.Session) error {
// check if user exists
if res, err := sess.Query("SELECT 1 from org_user WHERE org_id=? and user_id=?", cmd.OrgId, cmd.UserId); err != nil {
return err
} else if len(res) == 1 {
return m.ErrOrgUserAlreadyAdded
}
entity := m.OrgUser{
OrgId: cmd.OrgId,