Sha256: 7d578ec21651445ef481031ce6624c2bb91a7640c4e353f3ad0e56774993e4d9

Contents?: true

Size: 498 Bytes

Versions: 4

Compression:

Stored size: 498 Bytes

Contents

class SessionsController < ApplicationController
  def new
  end

  def create
    user = User.authenticate(params[:login], params[:password])
    if user
      session[:user_id] = user.id
      redirect_to_target_or_default root_url, :notice => "Logged in successfully."
    else
      flash.now[:alert] = "Invalid login or password."
      render :action => 'new'
    end
  end

  def destroy
    session[:user_id] = nil
    redirect_to root_url, :notice => "You have been logged out."
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
alondra-0.1.1 test/dummy/app/controllers/sessions_controller.rb
alondra-0.1.0 test/dummy/app/controllers/sessions_controller.rb
alondra-0.0.4 test/dummy/app/controllers/sessions_controller.rb
alondra-0.0.3 test/dummy/app/controllers/sessions_controller.rb