Chore: Delete SetUsingOrg from sqlstore (#59276)

* Chore: Delete SetUsingOrg drom sqlstore

* Adjust test

* Move test to dashboards

* Move test
This commit is contained in:
idafurjes
2022-11-28 14:59:40 +01:00
committed by GitHub
parent ae8acf178b
commit a7b2943dd1
5 changed files with 50 additions and 91 deletions
-22
View File
@@ -160,28 +160,6 @@ func NotServiceAccountFilter(ss *SQLStore) string {
ss.Dialect.BooleanStr(false))
}
// deprecated method, use only for tests
func (ss *SQLStore) SetUsingOrg(ctx context.Context, cmd *models.SetUsingOrgCommand) error {
getOrgsForUserCmd := &models.GetUserOrgListQuery{UserId: cmd.UserId}
if err := ss.GetUserOrgList(ctx, getOrgsForUserCmd); err != nil {
return err
}
valid := false
for _, other := range getOrgsForUserCmd.Result {
if other.OrgId == cmd.OrgId {
valid = true
}
}
if !valid {
return fmt.Errorf("user does not belong to org")
}
return ss.WithTransactionalDbSession(ctx, func(sess *DBSession) error {
return setUsingOrgInTransaction(sess, cmd.UserId, cmd.OrgId)
})
}
func setUsingOrgInTransaction(sess *DBSession, userID int64, orgID int64) error {
user := user.User{
ID: userID,