lib/slack/smart-bot/utils/has_access.rb in slack-smart-bot-1.14.2 vs lib/slack/smart-bot/utils/has_access.rb in slack-smart-bot-1.15.0
- old
+ new
@@ -1,27 +1,33 @@
class SlackSmartBot
def has_access?(method, user = nil)
user = Thread.current[:user] if user.nil?
+ team_id_user = "#{user.team_id}_#{user.name}"
if config[:allow_access].key?(method) and !config[:allow_access][method].include?(user.name) and !config[:allow_access][method].include?(user.id) and
- (!user.key?(:enterprise_user) or (user.key?(:enterprise_user) and !config[:allow_access][method].include?(user[:enterprise_user].id)))
+ !config[:allow_access][method].include?(team_id_user) and
+ (!user.key?(:enterprise_user) or (user.key?(:enterprise_user) and !config[:allow_access][method].include?(user[:enterprise_user].id) and
+ !config[:allow_access][method].include?("#{user[:enterprise_user].enterprise_id}_#{user[:enterprise_user].name}")))
respond "You don't have access to use this command, please contact an Admin to be able to use it: <@#{config.admins.join(">, <@")}>"
return false
else
if Thread.current[:typem] == :on_call
channel = Thread.current[:dchannel]
elsif Thread.current[:using_channel].to_s == ""
channel = Thread.current[:dest]
else
channel = Thread.current[:using_channel]
end
- if !@access_channels.key?(channel) or !@access_channels[channel].key?(method.to_s) or @access_channels[channel][method.to_s].include?(user.name)
+ if !@access_channels.key?(channel) or !@access_channels[channel].key?(method.to_s) or
+ @access_channels[channel][method.to_s].include?(user.name) or
+ @access_channels[channel][method.to_s].include?(team_id_user)
return true
else
if @admins_channels.key?(channel) and !@admins_channels[channel].empty?
- respond "You don't have access to use this command, please contact an Admin to be able to use it: <@#{@admins_channels[channel].join(">, <@")}>"
+ admins = @admins_channels[channel].map { |a| a.split('_')[1..-1].join('_') }
+ respond "You don't have access to use this command, please contact an Admin to be able to use it: <@#{admins.join(">, <@")}>"
else
respond "You don't have access to use this command, please contact an Admin to be able to use it."
- end
+ end
return false
end
end
end
end