Class: Puffer::Sessions::Simple

Inherits:
Base
  • Object
show all
Defined in:
lib/puffer/backends/controllers/sessions/simple.rb

Direct Known Subclasses

Admin::SessionsController

Instance Method Summary collapse

Instance Method Details

#createObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/puffer/backends/controllers/sessions/simple.rb', line 11

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

#destroyObject



23
24
25
26
# File 'lib/puffer/backends/controllers/sessions/simple.rb', line 23

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

#newObject



7
8
9
# File 'lib/puffer/backends/controllers/sessions/simple.rb', line 7

def new
  @record = resource.new_member
end