<commit_before>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'
            invite.notification_sent_at.present? ? 'notified' : 'notify'
           when 'accepted'
            invite.notification_sent_at.present? ? 'active' : 'notify'
           end

end

allow_impersonation = invite.present? ? user.confirmed? && invite.status == 'accepted' : true
<commit_msg>[MNOE-887] Enabled impersonation for new users<commit_after>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'
            invite.notification_sent_at.present? ? 'notified' : 'notify'
           when 'accepted'
            invite.notification_sent_at.present? ? 'active' : 'notify'
           end

end

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

{'fraction_non_alphanumeric': 0.10234445446348062, 'fraction_numerical': 0.001352569882777277, 'mean_word_length': 3.0345454545454547, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '985120', 'n_tokens_mistral': 691, 'n_tokens_neox': 682, 'n_words': 146}