Get screenshots for logged-in as well as anonymous users

This commit is contained in:
Christoph Haas 2017-08-14 19:06:39 +02:00
parent b1e8ebd9b4
commit 58ab5f1073

View file

@ -10,10 +10,12 @@ class ApplicationController < ActionController::Base
before_action :better_errors_hack, if: -> { Rails.env.development? }
# Query for packages that were uploaded by the current user.
# As AAA is not yet implemented it means looking for uploads
# that correspond to the user's cookie token.
# If the user is anonymous then find the uploads by the cookie token.
# If the user is logged in then find the uploads by matching the user id.
def get_current_users_screenshots
if session[:token]
if user_signed_in?
@current_users_screenshots = current_user.screenshots
else
@current_users_screenshots = Screenshot.uploaded_by(session[:token])
end
end