Sha256: ce29eb55f9c13edd1331e3e94964f81f4569c482d8fa586f2185447493720d2e

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

if member.is_a?(MnoEnterprise::User)
  json.uid member.uid
  json.entity 'User'
  json.role member.role(organization) if organization
  json.admin_role member.admin_role
  invite = MnoEnterprise::OrgInvite.find_by(user_id: member.id, organization_id: organization.id)

  status = case
           when member.confirmed?
            invite.blank? || invite.notification_sent_at.present? ? 'active' : 'notify'
           when member.confirmation_sent_at.nil? then 'pending'
           when !member.confirmed? then 'invited'
           end

  user = member
elsif member.is_a?(MnoEnterprise::OrgInvite)
  json.entity 'OrgInvite'
  json.role member.user_role
  user = member.user
  invite = member

  status = case member.status
           when 'staged' then 'pending'
           when 'pending'
            'invited'
           when 'accepted'
            invite.notification_sent_at.present? ? 'active' : 'notify'
           end

end

allow_impersonation = invite.present? ? invite.status == 'accepted' : true

json.extract! user, :id, :created_at, :email, :name, :surname
json.status status
json.allow_impersonation allow_impersonation

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mno-enterprise-api-3.4.0 app/views/mno_enterprise/jpi/v1/admin/base_resource/_member.json.jbuilder
mno-enterprise-api-3.3.3 app/views/mno_enterprise/jpi/v1/admin/base_resource/_member.json.jbuilder