Sha256: 24bbcbec2e2c183fe0312355133742027c6042afadeab7ba9ea01840bcae76c5

Contents?: true

Size: 910 Bytes

Versions: 12

Compression:

Stored size: 910 Bytes

Contents

class Admin::SessionController < Admin::BaseController

  skip_before_filter :reload_config_and_roles
  skip_before_filter :authenticate

  before_filter :create_an_account?, :only => [:new, :create]

  def new
  end

  def create
    user = user_scope.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
    deauthenticate
  end

  private

  def create_an_account?
    redirect_to new_admin_account_path if zero_users
  end

  def set_locale
    I18n.locale = Typus::I18n.default_locale
  end

  def user_scope
    klass = Typus.user_class
    klass.respond_to?(:in_domain) ? klass.in_domain(request.host) : klass
  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
typus-3.1.0.rc18 app/controllers/admin/session_controller.rb
typus-3.1.0.rc17 app/controllers/admin/session_controller.rb
typus-3.1.0.rc16 app/controllers/admin/session_controller.rb
typus-3.1.0.rc15 app/controllers/admin/session_controller.rb
typus-3.1.0.rc14 app/controllers/admin/session_controller.rb
typus-3.1.0.rc13 app/controllers/admin/session_controller.rb
typus-3.1.0.rc12 app/controllers/admin/session_controller.rb
typus-3.1.0.rc11 app/controllers/admin/session_controller.rb
typus-3.1.0.rc10 app/controllers/admin/session_controller.rb
typus-3.1.0.rc9 app/controllers/admin/session_controller.rb
typus-3.1.0.rc8 app/controllers/admin/session_controller.rb
typus-3.1.0.rc7 app/controllers/admin/session_controller.rb