Skip to content

Commit

Permalink
Ensured policy is only attached/removed for github users (#1438)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesstottmoj authored Jan 21, 2025
1 parent 078c9fb commit b93cd0f
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions controlpanel/api/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,18 @@ def reset_mfa(self):
auth0.ExtendedAuth0().users.reset_mfa(self.auth0_id)

def set_bedrock_access(self):
return cluster.User(self).update_policy_attachment(
policy=cluster.BEDROCK_POLICY_NAME,
attach=self.is_bedrock_enabled,
)
if self.is_github_user:
return cluster.User(self).update_policy_attachment(
policy=cluster.BEDROCK_POLICY_NAME,
attach=self.is_bedrock_enabled,
)

def set_quicksight_access(self, enable):
return cluster.User(self).update_policy_attachment(
policy=cluster.User.QUICKSIGHT_POLICY_NAME,
attach=enable,
)
if self.is_github_user:
return cluster.User(self).update_policy_attachment(
policy=cluster.User.QUICKSIGHT_POLICY_NAME,
attach=enable,
)

def save(self, *args, **kwargs):
existing = User.objects.filter(pk=self.pk).first()
Expand Down

0 comments on commit b93cd0f

Please sign in to comment.