This commit is contained in:
Alex Sherman 2020-09-29 14:17:00 +05:00
parent bb37527dae
commit 0d716e110a
4 changed files with 4 additions and 54 deletions

View file

@ -14,28 +14,12 @@ class User < ApplicationRecord
"#{self.id}-#{self.class}: #{self.username}"
end
# rubocop:disable Metrics/AbcSize
# def tampered_with?(omniauth_hash)
# # uid_from_hash = omniauth_hash['uid']
# # provider_from_hash = omniauth_hash['provider']
# #
# # begin
# # uid != uid_from_hash ||
# # provider != provider_from_hash ||
# # country_code != uid_from_hash.slice(0..1) ||
# # identity_code != uid_from_hash.slice(2..-1) ||
# # given_names != omniauth_hash.dig('info', 'first_name') ||
# # surname != omniauth_hash.dig('info', 'last_name')
# # end
# false
# end
# rubocop:enable Metrics/AbcSize
def self.from_omniauth(omniauth_hash)
uid = omniauth_hash['uid']
# provider = omniauth_hash['provider']
identity_code = uid.slice(2..-1)
country_code = uid.slice(0..1)
User.find_by(uid: uid)
User.find_by(identity_code: identity_code, country_code: country_code)
end
end