fix(): Check Organization exists before User is added (#5302)

Commit adds a check whether Organization exists before User is added to
the organization.

Fixes #3151.
This commit is contained in:
Zdenek Styblik
2016-06-08 05:46:21 +02:00
committed by Torkel Ödegaard
parent 67ad903556
commit 5eceabf810
2 changed files with 8 additions and 1 deletions

View File

@@ -26,6 +26,12 @@ func AddOrgUser(cmd *m.AddOrgUserCommand) error {
return m.ErrOrgUserAlreadyAdded
}
if res, err := sess.Query("SELECT 1 from org WHERE id=?", cmd.OrgId); err != nil {
return err
} else if len(res) != 1 {
return m.ErrOrgNotFound
}
entity := m.OrgUser{
OrgId: cmd.OrgId,
UserId: cmd.UserId,