index.js
function _setOrganization (cookies, cookieName, req, user) {
  if (!user) return
  // The order is important. The header can set explicitly on a query even if the cookie contradicts.
  const organizationId = req.headers['x-organizationid'] || cookies.get(cookieName + '_org')
  if (organizationId) {
    user.organization = (user.organizations || []).find(o => o.id === organizationId)

    if (user.organization) {
      user.consumerFlag = user.organization.id
    } else if (organizationId === '' || organizationId.toLowerCase() === 'user') {
      user.consumerFlag = 'user'
    }
  }
}
function _setOrganization (cookies, cookieName, req, user) {
  if (!user) return
  // The order is important. The header can set explicitly on a query even if the cookie contradicts.
  const organizationId = req.headers['x-organizationid'] || cookies.get(cookieName + '_org')
  if (organizationId) {
    user.organization = (user.organizations || []).find(o => o.id === organizationId)

    if (user.organization) {
      user.consumerFlag = user.organization.id
    } else if (organizationId === '' || organizationId.toLowerCase() === 'user') {
      user.consumerFlag = 'user'
    }
  }
}
function _setOrganization ( cookies , cookieName , req , user ) { if ( ! user ) return // The order is important. The header can set explicitly on a query even if the cookie contradicts. const organizationId = req . headers [ 'x-organizationid' ] || cookies . get ( cookieName + '_org' ) if ( organizationId ) { user . organization = ( user . organizations || [ ] ) . find ( o => o . id === organizationId ) if ( user . organization ) { user . consumerFlag = user . organization . id } else if ( organizationId === '' || organizationId . toLowerCase ( ) === 'user' ) { user . consumerFlag = 'user' } } }
Use complementary cookie id_token_org to set the current active organization of the user also set consumerFlag that is used by applications to decide if they should ask confirmation to the user of the right quotas or other organization related context to apply it is 'user' if id_token_org is an empty string or is equal to 'user' it is null if id_token_org is absent or if it does not match an organization of the current user it is the id of the orga in id_token_org
Use complementary cookie id_token_org to set the current active organization of the user also set consumerFlag that is used by applications to decide if they should ask confirmation to the user of the right quotas or other organization related context to apply it is user if id_token_org is an empty string or is equal to user it is null if id_token_org is absent or if it does not match an organization of the current user it is the id of the orga in id_token_org