Sha256: a0231e60571c3e9838cde33945da7e6c4869ff4b93c3eb2a4d474eed3b333df2

Contents?: true

Size: 917 Bytes

Versions: 11

Compression:

Stored size: 917 Bytes

Contents

class Admin::SessionController < Admin::BaseController

  skip_before_filter :reload_config_and_roles
  skip_before_filter :set_preferences
  skip_before_filter :authenticate

  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])

    if user
      session[:typus_user_id] = user.id
      path = params[:back_to] || admin_dashboard_path
    else
      alert = _t("The email and/or password you entered is invalid.")
      path = new_admin_session_path(:back_to => params[:back_to])
    end

    redirect_to path, :alert => alert
  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

11 entries across 11 versions & 1 rubygems

Version Path
typus-3.0.2 app/controllers/admin/session_controller.rb
typus-3.0.1 app/controllers/admin/session_controller.rb
typus-3.0.0 app/controllers/admin/session_controller.rb
typus-1.0.0.pre13 app/controllers/admin/session_controller.rb
typus-1.0.0.pre12 app/controllers/admin/session_controller.rb
typus-1.0.0.pre11 app/controllers/admin/session_controller.rb
typus-1.0.0.pre10 app/controllers/admin/session_controller.rb
typus-1.0.0.pre9 app/controllers/admin/session_controller.rb
typus-1.0.0.pre8 app/controllers/admin/session_controller.rb
typus-1.0.0.pre7 app/controllers/admin/session_controller.rb
typus-1.0.0.pre6 app/controllers/admin/session_controller.rb