sanger/sequencescape

View on GitHub
app/api/core/service/authentication.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
# frozen_string_literal: true
module Core::Service::Authentication
  class UnauthenticatedError < Core::Service::Error
    def self.no_cookie!
      raise self, 'no authentication provided'
    end

    def self.unauthenticated!
      raise self, 'could not be authenticated'
    end

    def api_error(response)
      response.general_error(401)
    end
  end

  module Helpers
    def user
      @user
    end
  end

  def self.registered(app)
    app.helpers Helpers
  end
end