Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Now every user manages its own dbdirect IPs #15805

Merged

Conversation

thedae
Copy link
Contributor

@thedae thedae commented Sep 2, 2020

Sync script to be executed in bch, this will clear redis and dump the dbdirect_ips from org owner to all users that belong to that org:

Carto::User.find_each do |user|
  $users_metadata.DEL('dbdirect:' + user.username)
  if user.organization.present?
    if user.organization.owner != user
      user.dbdirect_effective_ips = user.organization.owner.dbdirect_effective_ips
      user.save!
    end
  end
  if user.dbdirect_effective_ips.any?
    $users_metadata.HSETNX('dbdirect:' + user.username, 'ips', user.dbdirect_effective_ips.join(','))
  end
end

@thedae thedae requested a review from amiedes September 2, 2020 14:48
Copy link
Contributor

@amiedes amiedes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work 🙂

I've just left a suggestion about some code that I think can be refactored a bit.

app/models/carto/user.rb Show resolved Hide resolved
@thedae thedae requested a review from amiedes September 3, 2020 07:19
Copy link
Contributor

@amiedes amiedes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@thedae thedae merged commit 502062d into master Sep 3, 2020
@thedae thedae deleted the feature/ch98420/store-the-ip-firewall-information-in-redis branch September 3, 2020 09:16
@thedae thedae mentioned this pull request Sep 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants