Skip to content
This repository has been archived by the owner on Feb 28, 2024. It is now read-only.

Commit

Permalink
Merge pull request #4 from gaga5lala/prevent-query-for-invalid-obfusc…
Browse files Browse the repository at this point in the history
…ated-id

refactor: Prevent query for invalid obfuscated_id
  • Loading branch information
mguymon authored May 27, 2020
2 parents f426ada + 269c650 commit aeced4c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/obfuscate/obfuscatable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ def obfuscatable(options = {})
if append_salt
options[:salt] = "#{Obfuscate.config.salt}#{append_salt}"
end



config = Obfuscate.config.apply(options)

cattr_accessor :obfuscatable_config
Expand All @@ -60,7 +59,10 @@ class << self
#
# @return [Object]
def find_by_obfuscated_id( text )
find_by_id( clarify_id( text ) )
clarified_id = clarify_id( text )
return nil unless clarified_id.present?

find_by_id( clarified_id )
end

# Find by obfuscated_id
Expand Down Expand Up @@ -101,4 +103,4 @@ def obfuscate( text, mode = :string)
end
end

ActiveRecord::Base.send :include, Obfuscate::Obfuscatable
ActiveRecord::Base.send :include, Obfuscate::Obfuscatable

0 comments on commit aeced4c

Please sign in to comment.