21 lines
840 B
Ruby
21 lines
840 B
Ruby
class Users::MySessionsController < Devise::SessionsController
|
|
after_action :after_login, :only => :create
|
|
|
|
# Hook after successful login
|
|
def after_login
|
|
Log.log "User #{current_user.email} logged in.", request.remote_ip
|
|
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
|
|
# 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.email}.", request.remote_ip
|
|
session[:uploaded_screenshots] = nil
|
|
end
|
|
end
|
|
end
|