Skip to content

How to: Room's permissions and roles

daronco edited this page Apr 2, 2013 · 3 revisions

To control who can join a room, override the method bigbluebutton_role(room) in your application_controller.rb. The default implementation can be seen in controller_methods.rb and is very simple, so you really should implement your own method.

In this method, it can be useful to use owner_type and owner_id to check who is the owner of the room and private to check if the room is private or public. By default, a room has no owner (both owner_type and owner_id are nil) and is public (private is set to false).

Here's an example for an application where rooms can belong to users:

  def bigbluebutton_role(room)
    unless bigbluebutton_user.nil?           # there's a logged user
      if room.owner_type == "User"           # the room belongs to a user
        if room.owner.id == current_user.id
          :moderator                         # join as moderator if current_user owns this room
        else                                 # the current_user is not the owner
          if room.private
            nil                              # ask for a password if the room is private
          else
            :attendee                        # join as attendee if the room is public
          end
        end
      end
    else
      nil                                    # ask for a password for anonymous users
    end
  end

Note that this only allows you to control if the current user can join a room or not. If you need to control the access to controller actions (show, edit, destroy, etc.) you should check How to: Inherit controllers.

Clone this wiki locally