Files
astuto/app/helpers/o_auths_helper.rb
Riccardo Graziosi 4c73b398e8 Add OAuth2 authentication (#147)
- Added Site settings > Authentication section
- Create/edit/delete your custom oauth2 configurations
- Login or signup with oauth2
2022-08-05 18:15:17 +02:00

26 lines
623 B
Ruby

module OAuthsHelper
def query_path_from_hash(hash, path)
return nil unless hash.class == Hash and path.class == String
path_array = path
.split(Regexp.union([ '.', '[', ']' ])) # split by . and []
.filter { |v| not v.blank? } # remove possible blank values
.map do |v| # convert indexes to integer
if v == "0"
0
elsif v.to_i == 0
v
else
v.to_i
end
end
path_array.each do |selector|
break if hash == nil
hash = hash[selector]
end
hash
end
end