Chore: Delete SetUsingOrg from sqlstore (#59276)
* Chore: Delete SetUsingOrg drom sqlstore * Adjust test * Move test to dashboards * Move test
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user