Sha256: a254d7ab835cb4f34681e7fab3648c140b16adc7335bcf28964acab5fcf50d03

Contents?: true

Size: 494 Bytes

Versions: 13

Compression:

Stored size: 494 Bytes

Contents

module Shieldify
  module Controllers
    module Helpers
      def current_user
        warden.user
      end

      def user_signed_in?
        !!current_user
      end

      def authenticate_user!
        unless user_signed_in?
          respond_to_unauthorized
        end
      end

      private

      def warden
        request.env['warden']
      end

      def respond_to_unauthorized
        render json: { error: 'No autorizado' }, status: :unauthorized
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
shieldify-0.2.9.pre.alpha lib/shieldify/controllers/helpers.rb
shieldify-0.2.8.pre.alpha lib/shieldify/controllers/helpers.rb
shieldify-0.2.7.pre.alpha lib/shieldify/controllers/helpers.rb
shieldify-0.2.6.pre.alpha lib/shieldify/controllers/helpers.rb
shieldify-0.2.5.pre.alpha lib/shieldify/controllers/helpers.rb
shieldify-0.2.4.pre.alpha lib/shieldify/controllers/helpers.rb
shieldify-0.2.3.pre.alpha lib/shieldify/controllers/helpers.rb
shieldify-0.2.2.pre.alpha lib/shieldify/controllers/helpers.rb
shieldify-0.2.1.pre.alpha lib/shieldify/controllers/helpers.rb
shieldify-0.2.0.pre.alpha lib/shieldify/controllers/helpers.rb
shieldify-0.1.2.pre.alpha lib/shieldify/controllers/helpers.rb
shieldify-0.1.1.pre.alpha lib/shieldify/controllers/helpers.rb
shieldify-0.1.0.pre.alpha lib/shieldify/controllers/helpers.rb