From 9606889aac2698421effd8f121b4ea05b992675c Mon Sep 17 00:00:00 2001 From: Lee Lawlor Date: Sun, 29 Jun 2014 16:21:27 -0400 Subject: [PATCH] fix error when user doesn't own channel and tries to view api keys --- lib/api_keys.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/api_keys.rb b/lib/api_keys.rb index 0fcace5..7b00985 100644 --- a/lib/api_keys.rb +++ b/lib/api_keys.rb @@ -1,11 +1,12 @@ module ApiKeys - def api_index (channel_id) + def api_index(channel_id) if current_user && !current_user.channels.find_by_id(channel_id).nil? @channel = current_user.channels.find(channel_id) end - if current_user && current_user.id == @channel.user_id + if current_user.present? && @channel.present? && current_user.id == @channel.user_id @write_key = @channel.api_keys.write_keys.first @read_keys = @channel.api_keys.read_keys end end end +