mirror of
https://github.com/internetee/registry.git
synced 2025-08-06 01:35:10 +02:00
Use Tara user hash
This commit is contained in:
parent
a3042c39ee
commit
bb37527dae
3 changed files with 45 additions and 68 deletions
|
@ -15,34 +15,27 @@ class User < ApplicationRecord
|
|||
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
|
||||
# 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']
|
||||
# provider = omniauth_hash['provider']
|
||||
|
||||
User.find_or_initialize_by(provider: provider, uid: uid) do |user|
|
||||
user.given_names = omniauth_hash.dig('info', 'first_name')
|
||||
user.surname = omniauth_hash.dig('info', 'last_name')
|
||||
if provider == TARA_PROVIDER
|
||||
user.country_code = uid.slice(0..1)
|
||||
user.identity_code = uid.slice(2..-1)
|
||||
end
|
||||
end
|
||||
User.find_by(uid: uid)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue