Sha256: 88736ed5fbe3036ffc5d5f70adefa376ac1cdf0825b809ae7d1705f66e8baee0

Contents?: true

Size: 847 Bytes

Versions: 5

Compression:

Stored size: 847 Bytes

Contents

<%= @app_name %>::Admin.controllers :sessions do
  get :new do
    render "/sessions/new", nil, :layout => false
  end

  post :create do
    if account = <%= @model_name %>.authenticate(params[:email], params[:password])
      set_current_account(account)
      redirect url(:base, :index)
    elsif Padrino.env == :development && params[:bypass]
      <%- if @orm == :ohm -%>
      account = <%= @model_name %>.all.first
      <%- else -%>
      account = <%= @model_name %>.first
      <%- end -%>
      set_current_account(account)
      redirect url(:base, :index)
    else
      params[:email], params[:password] = h(params[:email]), h(params[:password])
      flash[:error] = pat('login.error')
      redirect url(:sessions, :new)
    end
  end

  delete :destroy do
    set_current_account(nil)
    redirect url(:sessions, :new)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
padrino-admin-0.11.4 lib/padrino-admin/generators/templates/app/controllers/sessions.rb.tt
padrino-admin-0.11.3 lib/padrino-admin/generators/templates/app/controllers/sessions.rb.tt
padrino-admin-0.11.2 lib/padrino-admin/generators/templates/app/controllers/sessions.rb.tt
padrino-admin-0.11.1 lib/padrino-admin/generators/templates/app/controllers/sessions.rb.tt
padrino-admin-0.11.0 lib/padrino-admin/generators/templates/app/controllers/sessions.rb.tt