Sha256: f82dd6063a6c7590182c8a496911380f31d7d92fa78df606cb29e0e992c21425

Contents?: true

Size: 799 Bytes

Versions: 32

Compression:

Stored size: 799 Bytes

Contents

# Creates (login) and destroys (logout) sessions
require_dependency "lines/application_controller"

module Lines

  class SessionsController < ApplicationController

    layout "lines/admin"

    
    # Renders form for creating a new article 
    def new
    end

    # Authenticate user and create a new session.
    def create
      user = Lines::User.find_by(email: params[:email])
      if user && user.authenticate(params[:password])
        session[:user_id] = user.id
        redirect_to admin_root_url, notice: "Logged in!"
      else
        flash.now.alert = "Email or password is invalid"
        render "new"
      end
    end

    # Destroys the current session (logout)
    def destroy
      session[:user_id] = nil
      redirect_to root_url, notice: "Logged out!"
    end
  end

end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
lines-engine-0.6.2 app/controllers/lines/sessions_controller.rb
lines-engine-0.6.1 app/controllers/lines/sessions_controller.rb
lines-engine-0.6 app/controllers/lines/sessions_controller.rb
lines-engine-0.5 app/controllers/lines/sessions_controller.rb
lines-engine-0.4.6.4 app/controllers/lines/sessions_controller.rb
lines-engine-0.4.6.3 app/controllers/lines/sessions_controller.rb
lines-engine-0.4.6.1 app/controllers/lines/sessions_controller.rb
lines-engine-0.4.6 app/controllers/lines/sessions_controller.rb
lines-engine-0.4.5 app/controllers/lines/sessions_controller.rb
lines-engine-0.4.4 app/controllers/lines/sessions_controller.rb
lines-engine-0.4.2 app/controllers/lines/sessions_controller.rb
lines-engine-0.4.1 app/controllers/lines/sessions_controller.rb
lines-engine-0.4 app/controllers/lines/sessions_controller.rb
lines-engine-0.3.3.2 app/controllers/lines/sessions_controller.rb
lines-engine-0.3.3.1 app/controllers/lines/sessions_controller.rb
lines-engine-0.3.3 app/controllers/lines/sessions_controller.rb
lines-engine-0.3.2 app/controllers/lines/sessions_controller.rb
lines-engine-0.3.1 app/controllers/lines/sessions_controller.rb
lines-engine-0.3 app/controllers/lines/sessions_controller.rb
lines-engine-0.2 app/controllers/lines/sessions_controller.rb