Sha256: 536b6934b8d17d17759f4dabbb2d088057193ccc6f3ef71b8664d089403c8a9a

Contents?: true

Size: 903 Bytes

Versions: 5

Compression:

Stored size: 903 Bytes

Contents

module Intro
  module Admin
    class SessionsController < ::Intro::Admin::ApplicationController
      if Rails::VERSION::MAJOR > 3
        before_action :unauthenticate, only: :new
        before_action :authenticate, only: :sign_out
      else
        before_filter :unauthenticate, only: :new
        before_filter :authenticate, only: :sign_out
      end

      def new; end

      def create
        if authenticated?
          session[:intro_admin_authenticated] = Intro.config.admin_username_digest
          redirect_to admin_tours_path
        else
          flash.now.alert = t('intro.errors.sign_in')
          render :new
        end
      end

      def sign_out
        session.delete(:intro_admin_authenticated)
        redirect_to unauthenticated_path
      end

      protected

      def unauthenticate
        redirect_to admin_tours_path if authenticated?
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
intro-0.4.1 app/controllers/intro/admin/sessions_controller.rb
intro-0.4.0 app/controllers/intro/admin/sessions_controller.rb
intro-0.3.0 app/controllers/intro/admin/sessions_controller.rb
intro-0.2.0 app/controllers/intro/admin/sessions_controller.rb
intro-0.1.0 app/controllers/intro/admin/sessions_controller.rb