Sha256: 7d70e9ca573039bb11b7c34f720ca5353912017cb667e8cb67f310c26e329601

Contents?: true

Size: 860 Bytes

Versions: 3

Compression:

Stored size: 860 Bytes

Contents

class Admin::SessionController < Admin::BaseController

  skip_before_filter :reload_config_and_roles, :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_index_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

3 entries across 3 versions & 1 rubygems

Version Path
typus-3.1.10 app/controllers/admin/session_controller.rb
typus-3.1.9 app/controllers/admin/session_controller.rb
typus-3.1.8 app/controllers/admin/session_controller.rb