class Doorkeeper::OAuth::PreAuthorization

def authorizable?

def authorizable?
  valid?
end

def error_response

def error_response
  Doorkeeper::OAuth::ErrorResponse.from_request(self)
end

def initialize(server, client, attrs = {})

def initialize(server, client, attrs = {})
  @server        = server
  @client        = client
  @response_type = attrs[:response_type]
  @redirect_uri  = attrs[:redirect_uri]
  @scope         = attrs[:scope]
  @state         = attrs[:state]
end

def scope

def scope
  @scope.presence || server.default_scopes.to_s
end

def scopes

def scopes
  Scopes.from_string scope
end

def validate_client

def validate_client
  client.present?
end

def validate_redirect_uri

TODO: test uri should be matched against the client's one
def validate_redirect_uri
  return false unless redirect_uri.present?
  Helpers::URIChecker.test_uri?(redirect_uri) ||
  Helpers::URIChecker.valid_for_authorization?(redirect_uri, client.redirect_uri)
end

def validate_response_type

def validate_response_type
  %w[code token].include? response_type
end

def validate_scopes

def validate_scopes
  return true unless scope.present?
  Helpers::ScopeChecker.valid? scope, server.scopes
end