Sha256: 46d56675531cc229b699b2acf64846732ca2b6a765c99f528a4bd9a878595a5e

Contents?: true

Size: 883 Bytes

Versions: 3

Compression:

Stored size: 883 Bytes

Contents

class Challah::SessionsController < ApplicationController
  before_filter :destroy_session, :except => :create
  
  unloadable
  
  # GET /login
  def new
    @session = Challah::Session.new(request)
  end
  
  # POST /login
  def create
    @session = Challah::Session.new(request, params[:session])
    @session.ip = request.remote_ip
    
    if @session.save
      redirect_to return_to_path(@session.default_path)
    else
      redirect_to login_path, :alert => I18n.translate('challah.sessions.create.failed_login')
    end
  end
  
  # GET /logout
  def destroy
    redirect_to login_path
  end
  
  protected
    def destroy_session
      current_user_session.destroy
    end
  
    def return_to_path(default_path = '/')
      result = session[:return_to]      
      result = nil if result and result == "http://#{request.domain}/"
      result || default_path
    end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
challah-0.3.0 app/controllers/challah/sessions_controller.rb
challah-0.2.1 app/controllers/challah/sessions_controller.rb
challah-0.2.0 app/controllers/challah/sessions_controller.rb