Sha256: 873e732e5a83d7bcc50e4153b5877e0eb204b509603e75571cb118ae550c40fb

Contents?: true

Size: 963 Bytes

Versions: 3

Compression:

Stored size: 963 Bytes

Contents

if defined?(ApplicationController)
  class SessionsController < ApplicationController
    before_filter :destroy_session, except: :create

    unloadable

    # GET /login
    # GET /sign-in
    def new
      @session = Challah::Session.new(request)
    end

    # POST /login
    # POST /sign-in
    def create
      @session = Challah::Session.new(request, params[:session])
      @session.ip = request.remote_ip

      if @session.save
        redirect_to return_to_path
      else
        redirect_to signin_path, alert: I18n.translate('sessions.create.failed_login')
      end
    end

    # GET /logout
    # GET /sign-out
    def destroy
      redirect_to signin_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
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
challah-1.2.11 app/controllers/sessions_controller.rb
challah-1.2.10 app/controllers/sessions_controller.rb
challah-1.2.9 app/controllers/sessions_controller.rb