Sha256: 961caf685e687f4860c7de5e6a10af25a61c27bf2c47319abd8b547bed287190
Contents?: true
Size: 845 Bytes
Versions: 3
Compression:
Stored size: 845 Bytes
Contents
module ApiUserAuth # Model for social provider registration class ProviderToken < ApplicationRecord belongs_to :auth_user, class_name: 'ApiUserAuth::AuthUser' enum provider: %I[facebook google instagram] def self.find_by_data(data) find_by( provider: data[:provider], user_id: data[:id] ) end 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 def self.create_auth_user(data) email = data[:id] + '@' + data[:provider] + '.com' AuthUser.create(email: email, password: SecureRandom.uuid) end end end
Version data entries
3 entries across 3 versions & 1 rubygems