Sha256: fc071ee948fd15d7f1feedd246b18aff16c287f6c1aac80a3753e3fcb326757c

Contents?: true

Size: 962 Bytes

Versions: 1

Compression:

Stored size: 962 Bytes

Contents

class <%= user_session_plural_class_name %> < ApplicationController

  skip_before_filter :require_<%= user_singular_name %>, :only => [:new, :create]
  before_filter :require_no_<%= user_singular_name %>, :only => [:new, :create]
  before_filter :require_<%= user_singular_name %>, :only => :destroy

  def new
    @<%= user_session_singular_name %> = <%= user_session_class_name %>.new
  end

  def create
    @<%= user_session_singular_name %> = <%= user_session_class_name %>.new(params[:<%= user_session_singular_name %>])
    if @<%= user_session_singular_name %>.save
      set_flash
      redirect_back_or_default root_url
    else
      failed_sign_in_flash
      render :new
    end
  end

  def destroy
    current_<%= user_session_singular_name %>.destroy
    set_flash
    redirect_back_or_default root_url
  end

  private

  def failed_sign_in_flash
    @<%= user_session_singular_name %>.errors.clear
    set_flash_now :error, :failed
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
iain-pizza-generators-0.1.4 rails_generators/pizza_authentication/templates/sessions_controller.rb