Sha256: ca3d0027b335b606b5702ddc611b1f5d58a5c9a36b56f3d9758279b22bf464ef

Contents?: true

Size: 939 Bytes

Versions: 7

Compression:

Stored size: 939 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 = I18n.default_locale
  end

  def user_scope
    if Typus.user_class.scopes.include?(:in_domain)
      Typus.user_class.in_domain(request.host)
    else
      Typus.user_class
    end
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
typus-3.0.12 app/controllers/admin/session_controller.rb
typus-3.0.11 app/controllers/admin/session_controller.rb
typus-3.0.11.rc5 app/controllers/admin/session_controller.rb
typus-3.0.11.rc4 app/controllers/admin/session_controller.rb
typus-3.0.11.rc3 app/controllers/admin/session_controller.rb
typus-3.0.11.rc2 app/controllers/admin/session_controller.rb
typus-3.0.11.rc1 app/controllers/admin/session_controller.rb