Production Build Working
This commit is contained in:
+39
-42
@@ -2,7 +2,7 @@ class User < ApplicationRecord
|
||||
include Devise::JWT::RevocationStrategies::JTIMatcher
|
||||
|
||||
devise :database_authenticatable, :registerable,
|
||||
:validatable, :jwt_authenticatable, jwt_revocation_strategy: self
|
||||
:validatable, :recoverable, :jwt_authenticatable, jwt_revocation_strategy: self
|
||||
# Include default devise modules. Others available are:
|
||||
# :recoverable, :rememberable, :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
|
||||
|
||||
@@ -30,46 +30,34 @@ class User < ApplicationRecord
|
||||
@keychain ||= case role
|
||||
when "member"
|
||||
if role_entity.present?
|
||||
# belongs_to = {
|
||||
# employer_id: role_entity.employer_id,
|
||||
# broker_id: role_entity&.baclight_employer.broker_id,
|
||||
# carrier_id:role_entity&.baclight_employer&.baclight_broker&.carrier_id
|
||||
# }
|
||||
keys = role_entity.attributes.with_indifferent_access.slice(
|
||||
:id, :name, :family_id, :mb_member_key, :pb_entity_key, :pl_plan_key
|
||||
role_entity.attributes.with_indifferent_access.slice(
|
||||
:id, :name, :family_id, :mb_member_key, :pb_entity_key, :pl_plan_key, :employer_id
|
||||
)
|
||||
|
||||
keys #.merge(belongs_to)
|
||||
end
|
||||
when "employer"
|
||||
if role_entity.present?
|
||||
belongs_to = role_entity.joins(broker: :carrier).select(
|
||||
'brokers.id AS broker_id',
|
||||
'carriers.id AS carrier_id'
|
||||
role_entity.attributes.with_indifferent_access.slice(
|
||||
:id, :name, :pl_plan_key, :company_pb_entity_key, :plan_id, :group_number
|
||||
)
|
||||
|
||||
|
||||
keys = role_entity.attributes.with_indifferent_access.slice(
|
||||
:name, :pl_plan_key, :company_pb_entity_key, :plan_id, :group_number
|
||||
)
|
||||
|
||||
keys.merge(belongs_to)
|
||||
end
|
||||
when "broker"
|
||||
if role_entity.present?
|
||||
belongs_to = role_entity.joins(:carrier).select(
|
||||
'carriers.id AS carrier_id'
|
||||
)
|
||||
role_entity.attributes.with_indifferent_access.slice(
|
||||
:name, :id
|
||||
).merge(belongs_to)
|
||||
end
|
||||
when "provider"
|
||||
if role_entity.present?
|
||||
role_entity.attributes.with_indifferent_access.slice(
|
||||
:name, :pb_entity_key, :tax_id, :family_id
|
||||
)
|
||||
end
|
||||
when "provider"
|
||||
{
|
||||
id: self.id,
|
||||
name: self.name,
|
||||
tax_id: self.role_id
|
||||
}
|
||||
# if role_entity.present?
|
||||
# role_entity.attributes.with_indifferent_access.slice(
|
||||
# :id, :name, :pb_entity_key, :tax_id, :family_id
|
||||
# )
|
||||
# end
|
||||
when "carrier"
|
||||
if role_entity.present?
|
||||
role_entity.attributes.with_indifferent_access.slice(
|
||||
@@ -77,6 +65,11 @@ class User < ApplicationRecord
|
||||
)
|
||||
end
|
||||
# when "admin"
|
||||
# if role_entity.present?
|
||||
# role_entity.attributes.with_indifferent_access.slice(
|
||||
# :name, :id
|
||||
# )
|
||||
# end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -91,33 +84,37 @@ class User < ApplicationRecord
|
||||
find_initial_member
|
||||
end
|
||||
when "employer"
|
||||
Baclight::Employer.find_by(company_pb_entity_key: role_id)
|
||||
Baclight::Employer.find_by(pl_plan_key: role_id)
|
||||
when "broker"
|
||||
Baclight::Broker.find_by(broker_id: role_id)
|
||||
Baclight::Broker.find_by(id: role_id)
|
||||
when "provider"
|
||||
Baclight::Provider.find_by(tax_id: role_id)
|
||||
when "carrier"
|
||||
Baclight::Carrier.find_by(carrier_id: role_id)
|
||||
Baclight::Carrier.find_by(id: role_id)
|
||||
# when "admin"
|
||||
end
|
||||
end
|
||||
|
||||
def sync_role_entity
|
||||
if role == "member"
|
||||
self.name = role_entity.name.split(",").reverse.join(" ").squish
|
||||
else
|
||||
self.name = role_entity.name
|
||||
unless role == "provider"
|
||||
if role == "member"
|
||||
self.name = role_entity.name.split(",").reverse.join(" ").squish
|
||||
else
|
||||
self.name = role_entity.name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def role_entity_exists
|
||||
if role_entity.blank?
|
||||
errors.add(:role, "#{role} with id #{role_id} was not found.")
|
||||
end
|
||||
if role == "member"
|
||||
dob = Vhcs::VwmbMember.find_by(pb_entity_key: role_id).date_of_birth
|
||||
unless dob == date_of_birth
|
||||
errors.add(:role, "#{role} with id #{role_id} and #{date_of_birth} was not found.")
|
||||
unless role == "provider"
|
||||
if role_entity.blank?
|
||||
errors.add(:role, "#{role} with id #{role_id} was not found.")
|
||||
end
|
||||
if role == "member"
|
||||
dob = Vhcs::VwmbMember.find_by(pb_entity_key: role_id).date_of_birth
|
||||
unless dob == date_of_birth
|
||||
errors.add(:role, "#{role} with id #{role_id} and #{date_of_birth} was not found.")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user