# Class: Users::MySessionsController

Inherits:
  Devise::SessionsController
  - Object
  - Devise::SessionsController
  - Users::MySessionsController
  show all

Defined in:
  app/controllers/users/my_sessions_controller.rb

## Instance Method Summary collapse

- #after_login ⇒ Object

  Hook after successful login.

## Instance Method Details

### #after_login ⇒ `Object`

Hook after successful login

    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20

    # File 'app/controllers/users/my_sessions_controller.rb', line 5

    def after_login
      Log.log "User #{current_user} logged in."
      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}."
        session[:uploaded_screenshots] = nil
      end
    end