mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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:
committed by
Torkel Ödegaard
parent
67ad903556
commit
5eceabf810
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user