Sha256: ea004e4a1f951d2674d61e922cab3454c0fbd605a0ee6d10d5661a25eb88bb2b

Contents?: true

Size: 635 Bytes

Versions: 1

Compression:

Stored size: 635 Bytes

Contents

class Puffer::Sessions::Simple < Puffer::Sessions::Base

  setup do
    model_name :puffer_user
  end

  def new
    @record = resource.new_member
  end

  def create
    @record = resource.adapter.find_first(:conditions => {:email => resource.attributes[:email]})

    if @record && @record.authenticate(resource.attributes[:password])
      session[:puffer_user_id] = @record.id
      redirect_back_or admin_root_url
    else
      @record = resource.new_member :email => resource.attributes[:email]
      render 'new'
    end
  end

  def destroy
    session.delete(:puffer_user_id)
    redirect_to new_admin_session_url
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
puffer-0.1.1 lib/puffer/backends/controllers/sessions/simple.rb