kandanapp / kandan

Kandan is an Open Source Alternative to HipChat
GNU Affero General Public License v3.0
2.72k stars 405 forks source link

proposal: Restrict users to channels defined by admin #291

Open marcnaweb opened 10 years ago

marcnaweb commented 10 years ago

The idea is to restrict user to certain channels defined by the admin. I tried to do so by my own and went well on restricting the channels to be accessed / updated by "non-authorized users", however, I can't see a way to avoid users from appearing in the people side bar / in the bot 'connected / disconnected' activity if they don't access the same channel as the 'current user'. What do you think? (any suggestion/ is this out of scope of this project?)

jrgifford commented 10 years ago

Not out of scope, just more complex than it sounds.

marcnaweb commented 10 years ago

Thanks : ) Actually, I did the restriction by adding a 'allowed_channels' field in the user model. Then I created:

 before_filter :check_if_allowed,

with

def check_if_allowed
    if current_user.allowed_channels.split(',').include?(params[:channel_id].to_s)
      return true
    else
      return false
    end

  end

I modify all the rest accordingly, but got stuck in the 'people' and bot 'connected/disconnected' side of the app. would you like that I send you the code? --> it just a starting point, but might help if you plan to implement so.

jrgifford commented 10 years ago

If you could submit a pull request, we can go ahead and mark it as a "incoming" feature, and we can help. :)

marcnaweb commented 10 years ago

ok, done the "pull request". Thanks for all!.. ;)