Sha256: ede59f79bec6d653ddbe8bc4469d02f503772761b6964a180b45e17c047252ed

Contents?: true

Size: 934 Bytes

Versions: 13

Compression:

Stored size: 934 Bytes

Contents

# This controller handles the login/logout function of the site.  
class SessionsController < ApplicationController
  def new
    #Stub required for Lockdown to grant access
  end

  def create
    password_authentication(params[:login], params[:password])
  end

  def destroy
		logger.info "resetting session in sessions controller"
    reset_session
    flash[:notice] = "You have been logged out."
    redirect_back_or_default('/')
  end
  
  protected

  def password_authentication(login, password)
    set_session_user(User.authenticate(login, password))
    if logged_in?
      successful_login
    else
      failed_login
    end
  end
  
  def failed_login(message = 'Authentication failed.')
    flash[:error] = message
    redirect_back_or_default login_url
  end
	 
  def successful_login
    flash[:notice] = "Logged in successfully"
    redirect_back_or_default Lockdown::System.fetch(:successful_login_path)
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
lockdown-0.5.10 rails_generators/lockdown/templates/app/controllers/sessions_controller.rb
lockdown-0.5.11 rails_generators/lockdown/templates/app/controllers/sessions_controller.rb
lockdown-0.5.12 rails_generators/lockdown/templates/app/controllers/sessions_controller.rb
lockdown-0.5.0 rails_generators/lockdown/templates/app/controllers/sessions_controller.rb
lockdown-0.5.1 rails_generators/lockdown/templates/app/controllers/sessions_controller.rb
lockdown-0.5.7 rails_generators/lockdown/templates/app/controllers/sessions_controller.rb
lockdown-0.5.8 rails_generators/lockdown/templates/app/controllers/sessions_controller.rb
lockdown-0.5.4 rails_generators/lockdown/templates/app/controllers/sessions_controller.rb
lockdown-0.5.9 rails_generators/lockdown/templates/app/controllers/sessions_controller.rb
lockdown-0.5.2 rails_generators/lockdown/templates/app/controllers/sessions_controller.rb
lockdown-0.5.3 rails_generators/lockdown/templates/app/controllers/sessions_controller.rb
lockdown-0.5.5 rails_generators/lockdown/templates/app/controllers/sessions_controller.rb
lockdown-0.5.6 rails_generators/lockdown/templates/app/controllers/sessions_controller.rb