Sha256: 010c2098e854753b56761a7886884e869e45b957e6f4d4c694d15dea29c5b189

Contents?: true

Size: 691 Bytes

Versions: 11

Compression:

Stored size: 691 Bytes

Contents

module Spina
  module Admin
    class AdminController < ::Spina::ApplicationController
      before_action :set_admin_locale
      before_action :authorize_spina_user

      def current_admin_path
        request.fullpath[%r{/#{ Spina.config.backend_path }(.*)}, 1]
      end
      helper_method :current_admin_path

      private

      def set_admin_locale
        I18n.locale = I18n.default_locale
      end

      def authorize_spina_user
        redirect_to admin_login_path, flash: {information: I18n.t('spina.notifications.login')} unless current_spina_user
      end

      def authorize_admin
        render status: 401 unless current_spina_user.admin?
      end

    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
spina-2.0.0.alpha app/controllers/spina/admin/admin_controller.rb
spina-1.2.0 app/controllers/spina/admin/admin_controller.rb
spina-1.1.4 app/controllers/spina/admin/admin_controller.rb
spina-1.1.3 app/controllers/spina/admin/admin_controller.rb
spina-1.1.2 app/controllers/spina/admin/admin_controller.rb
spina-1.1.1 app/controllers/spina/admin/admin_controller.rb
spina-1.1.0 app/controllers/spina/admin/admin_controller.rb
spina-1.0.3 app/controllers/spina/admin/admin_controller.rb
spina-1.0.2 app/controllers/spina/admin/admin_controller.rb
spina-1.0.1 app/controllers/spina/admin/admin_controller.rb
spina-1.0.0 app/controllers/spina/admin/admin_controller.rb