Sha256: ae96e4fd9cc751bb5ffb550a75c028648ae6df6602e87de5c2ba6ed5a04320f7

Contents?: true

Size: 757 Bytes

Versions: 3

Compression:

Stored size: 757 Bytes

Contents

# Implemented basic rails auth with custom PufferUser model.
# Admin::SessionsController could be redefined in application.
# See Puffer::SessionsBase docs for additional info.
class Admin::SessionsController < Puffer::SessionsBase

  def new
    @record = PufferUser.new
  end

  def create
    @record = PufferUser.to_adapter.find_first(:conditions => {:email => params[:puffer_user][:email]})
    if @record && @record.authenticate(params[:puffer_user][:password])
      session[:puffer_user_id] = @record.id
      redirect_to admin_root_url
    else
      @record = PufferUser.new :email => params[:puffer_user][:email]
      render 'new'
    end
  end

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

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
puffer-0.0.32 app/controllers/admin/sessions_controller.rb
puffer-0.0.31 app/controllers/admin/sessions_controller.rb
puffer-0.0.30 app/controllers/admin/sessions_controller.rb