class SessionsController < ApplicationController
  layout 'admin'
  filter_parameter_logging 'password', 'password_confirmation'

  def create
    if (@session = UserSession.create(params[:session]))
      redirect_back_or_default(admin_root_url)
      flash[:notice] = "Logged in successfully"
    else
      render :action => 'new'
    end
  end

  def destroy
    current_user_session.destroy if logged_in?
    flash[:notice] = "You have been logged out."
    redirect_back_or_default(new_session_url)
  end

protected

  def take_down_for_maintenance?;end

end

class SessionsController < ApplicationController
  layout 'admin'
  filter_parameter_logging 'password', 'password_confirmation'

  def create
    @session = UserSession.new(params[:session])
    if @session.save
      redirect_back_or_default(admin_root_url)
      flash[:notice] = "Logged in successfully"
    else
      render :action => 'new'
    end
  end

  def destroy
    current_user_session.destroy if logged_in?
    flash[:notice] = "You have been logged out."
    redirect_back_or_default(new_session_url)
  end

protected

  def take_down_for_maintenance?;end

end

Fix a bug where it would always say "Logged in successfully" even when they weren't logged in successfully.
Fix a bug where it would always say "Logged in successfully" even when
they weren't logged in successfully.

Somewhat confusingly, UserSession.create is not the same as
UserSession.new.save. UserSession.create will return a UserSession
object (such #<UserSession: no credentials provided>), even if there was
an authentication error. This changes it back to use save, which returns
true or false.
