Roles
Admins
Users with the admin flag set to true will be allowed to access the application's admin interface, Sidekiq web UI, and more.
To set a user as an admin, simply update their admin flag: Jumpstart.grant_system_admin! user from the Rails console.
You can check this flag if you would like to restrict any functionality only to admin users.
Organization Roles
Users can be assigned a role for each organization they are a part of. By default, we only provide an admin role, but you can add more roles in app/models/organization_user.rb. These roles will be listed in the UI when adding or editing a organization member. You should not use a reserved word (like "user") as the name of a role; this will cause an error when attempting to create an organization.
You can check the role on the organization member to restrict access to certain functionality on the organization as needed.
To access the current organization member or roles, you can use the following helpers in your controllers and views:
Current.organization_user #=> OrganizationUser
Current.roles #=> [:admin]
You can also access the roles individually on the OrganizationUser model:
organization_user = OrganizationUser.new
organization_user.admin? #=> false
organization_user.admin = true
organization_user.admin? #=> true
organization_user.active_roles #=> [:admin]