Sha256: af3610fca3c1deef69c36bf37c88c7e7608168065090b06ee6e4d54150d2cbfb
Contents?: true
Size: 729 Bytes
Versions: 6
Compression:
Stored size: 729 Bytes
Contents
require 'uri' class RedirectUriValidator < ActiveModel::EachValidator def self.test_redirect_uri Doorkeeper.configuration.test_redirect_uri end def validate_each(record, attribute, value) uri = ::URI.parse(value) return if test_redirect_uri?(uri) record.errors.add(attribute, :fragment_present) unless uri.fragment.nil? record.errors.add(attribute, :relative_uri) if uri.scheme.nil? || uri.host.nil? record.errors.add(attribute, :has_query_parameter) unless uri.query.nil? rescue URI::InvalidURIError record.errors.add(attribute, :invalid_uri) end private def test_redirect_uri?(uri) self.class.test_redirect_uri.present? && uri.to_s == self.class.test_redirect_uri.to_s end end
Version data entries
6 entries across 6 versions & 1 rubygems