Sha256: 1c14c3596dc3f73a72f30794211959533811e7e3dfc32d98c2de0532c376bc18

Contents?: true

Size: 910 Bytes

Versions: 1

Compression:

Stored size: 910 Bytes

Contents

class Admin::SessionController < AdminController

  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 = _("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

1 entries across 1 versions & 1 rubygems

Version Path
typus-1.0.0.pre app/controllers/admin/session_controller.rb