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

added user rake task set_admin_role #5587

Merged

Conversation

SilentFlameCR
Copy link
Contributor

Fixes #5515

Comment on lines 50 to 67
if email.blank?
info 'Please provide an email address of the user you wish to set to Administrator role.'
else
user = User.find_by(email:, provider: 'greenlight')
if user
role = Role.find_by(name: 'Administrator', provider: 'greenlight')
if role
user.role = role
user.save!
success "User role set to Administrator for email: #{email}"
else
info "Role 'Administrator' not found for provider 'greenlight'"
end
else
info "User with email: #{email} not found"
end
end
end
Copy link
Collaborator

@farhatahmad farhatahmad Nov 28, 2023

Choose a reason for hiding this comment

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

The nested ifs make this super difficult to follow. Might be clearer to use guard clauses here instead

user = User.find_by(email:, provider: 'greenlight')
err 'User with email: #{email} not found' if user.blank?
...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah that sounds good. I updated the code with the guard clauses so its easier to read!

Comment on lines 63 to 64
user.role = role
user.save!
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can do this in one line user.update(role:)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

got it and updated!

Copy link

sonarcloud bot commented Nov 28, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.4% 0.4% Duplication

@farhatahmad farhatahmad merged commit 7422a46 into bigbluebutton:master Dec 13, 2023
4 checks passed
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.

[v3] No practical way to create/use (super) admin accounts with SSO enabled.
2 participants