SpinaCMS/Spina

View on GitHub
lib/spina/authentication/basic.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
91%
module Spina
  module Authentication
    module Basic
      extend ActiveSupport::Concern

      included do
        helper_method :logged_in?
      end

      def logged_in?
        authenticate
      end

      private

      def authenticate
        authenticate_or_request_with_http_basic do |username, password|
          username == Rails.application.credentials.dig(:spina, :username) && password == Rails.application.credentials.dig(:spina, :password)
        end
      end
    end
  end
end