Sha256: 098b4066bf7f96e00e2f164c9168fea312bec7d388ef1b87b95bee119aca85df

Contents?: true

Size: 939 Bytes

Versions: 2

Compression:

Stored size: 939 Bytes

Contents

class Spud::Admin::UserSessionsController < Spud::ApplicationController

  before_filter :require_user, :only => :destroy
  layout 'spud/login/application'

  def new
    if current_user
      redirect_to spud_admin_root_path
    elsif SpudUser.all.count == 0
      logger.debug "NO USERS!"
      redirect_to spud_setup_url() and return
    end
    @user_session = SpudUserSession.new
  end
  
  def create
    @user_session = SpudUserSession.new(params[:spud_user_session])
    if @user_session.save
      flash[:notice] = "Login successful!"
      redirect_to spud_admin_root_path
    else
      render :action => :new
    end
  end
  
  def destroy
    current_user_session.destroy
    flash[:notice] = "Logout successful!"
    if !request.referer.blank?
      session[:return_to] = request.referer
    end
    redirect_back_or_default spud_admin_login_path
  end

  def legacy_redirect
    redirect_to spud_admin_login_path
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tb_core-1.0.2 app/controllers/spud/admin/user_sessions_controller.rb
tb_core-1.0.1 app/controllers/spud/admin/user_sessions_controller.rb