Sha256: 404443bb6ad6aa4a8d39f1028cf119c0eb63cde636b9bcbf71619b8510e0b8de

Contents?: true

Size: 900 Bytes

Versions: 13

Compression:

Stored size: 900 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
    email, password = admin_user_params[:email], admin_user_params[:password]
    user = user_scope.authenticate(email, password)

    path = if user
      session[:typus_user_id] = user.id
      params[:return_to] || admin_dashboard_index_path
    else
      new_admin_session_path(:return_to => params[:return_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

13 entries across 13 versions & 1 rubygems

Version Path
brainsome_typus-4.0.0.beta13 app/controllers/admin/session_controller.rb
brainsome_typus-4.0.0.beta12 app/controllers/admin/session_controller.rb
brainsome_typus-4.0.0.beta11 app/controllers/admin/session_controller.rb
brainsome_typus-4.0.0.beta10 app/controllers/admin/session_controller.rb
brainsome_typus-4.0.0.beta9 app/controllers/admin/session_controller.rb
brainsome_typus-4.0.0.beta8 app/controllers/admin/session_controller.rb
brainsome_typus-4.0.0.beta7 app/controllers/admin/session_controller.rb
brainsome_typus-4.0.0.beta6 app/controllers/admin/session_controller.rb
brainsome_typus-4.0.0.beta5 app/controllers/admin/session_controller.rb
brainsome_typus-4.0.0.beta4 app/controllers/admin/session_controller.rb
brainsome_typus-4.0.0.beta3 app/controllers/admin/session_controller.rb
brainsome_typus-4.0.0.beta2 app/controllers/admin/session_controller.rb
brainsome_typus-4.0.0.beta1 app/controllers/admin/session_controller.rb