Class: ApiUserAuth::ProviderToken
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- ApiUserAuth::ProviderToken
- Defined in:
- app/models/api_user_auth/provider_token.rb
Overview
Model for social provider registration
Class Method Summary collapse
- .create_auth_user(data) ⇒ Object
- .create_by_data(data, auth_user) ⇒ Object
- .find_by_data(data) ⇒ Object
Class Method Details
.create_auth_user(data) ⇒ Object
29 30 31 32 |
# File 'app/models/api_user_auth/provider_token.rb', line 29 def self.create_auth_user(data) email = data[:id] + '@' + data[:provider] + '.com' AuthUser.create(email: email, password: SecureRandom.uuid) end |
.create_by_data(data, auth_user) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/models/api_user_auth/provider_token.rb', line 16 def self.create_by_data(data, auth_user) auth_user ||= create_auth_user(data) if find_by_data(data).blank? auth_user.provider_tokens.create( provider: data[:provider], user_id: data[:id], user_data: data ) else nil end end |
.find_by_data(data) ⇒ Object
9 10 11 12 13 14 |
# File 'app/models/api_user_auth/provider_token.rb', line 9 def self.find_by_data(data) find_by( provider: data[:provider], user_id: data[:id] ) end |