Sha256: 4070c0261ca193789a0e2bc1ed13bcdd4b2fb34fa4b640ba74f48a10e43e781c

Contents?: true

Size: 853 Bytes

Versions: 3

Compression:

Stored size: 853 Bytes

Contents

class Admin::SessionController < Admin::BaseController

  skip_before_filter :reload_config_and_roles
  skip_before_filter :authenticate
  skip_before_filter :set_locale

  before_filter :create_an_account?, :except => [:destroy]

  def new
  end

  def create
    user = Typus.user_class.authenticate(params[:typus_user][:email], params[:typus_user][:password])

    path = if user
             session[:typus_user_id] = user.id
             params[:back_to] || admin_dashboard_path
           else
             new_admin_session_path(:back_to => params[:back_to])
           end

    redirect_to path
  end

  def destroy
    session[:typus_user_id] = nil
    I18n.locale = I18n.default_locale
    redirect_to :action => :new
  end

  private

  def create_an_account?
    redirect_to new_admin_account_path if Typus.user_class.count.zero?
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
typus-3.0.6 app/controllers/admin/session_controller.rb
typus-3.0.5 app/controllers/admin/session_controller.rb
typus-3.0.4 app/controllers/admin/session_controller.rb