upload screenshot anonymously, login in, get screenshots assigned

This commit is contained in:
Christoph Haas 2018-08-21 18:25:18 +02:00
parent 820ff2a30b
commit 2746b22c18
4 changed files with 70 additions and 32 deletions

View file

@ -7,12 +7,14 @@ class Users::MySessionsController < Devise::SessionsController
old_screenshots = session[:uploaded_screenshots]
if old_screenshots.to_a.length > 0
old_screenshots.each do |id|
next unless id # sometimes we had 'nil' here
ss = Screenshot.find(id)
ss.user = @user
ss.save!
end
flash[:info] = "#{old_screenshots.to_a.length} uploads have been added to your account"
Log.log "Anonymously uploaded screenshots #{old_screenshots} added to account."
# The message is probably confusing. Just add the screenshots.
# flash[:info] = "#{old_screenshots.to_a.length} uploads have been added to your account"
Log.log "Anonymously uploaded screenshots #{old_screenshots} added to #{current_user}."
session[:uploaded_screenshots] = nil
end
end