Skip to main content

Codex context

Introduction

When developing plugins for Codex you need access to the curent context of the users using the plugin, such as the user information, organization information, site or even permissions.

To make the development easier, Codex provides a codexContext object which gives information about the context of the current user using the plugin.

To access the codexContext you need to inject it into your component:

<script>
export default {
inject: ['codexContext'],
}
</script>

User context

As part of the codexContext you can get information about the current user. When you access codexContext.user you get the following result:

codexContext.user
{
"id": "userId",
"fullName": "userFullName",
"email": "userEmail",
"picture": "userProfilePictureUrl"
}

Site context

As part of the codexContext you can get information about the current site the user is working on. When you access codexContext.site you get the following result:

codexContext.site
{
"id": "siteId",
"name": "siteName",
"alias": "siteAlias",
"domain": "siteDomain",
"logo": "siteLogoUrl",
"description": "siteDescription",
"attrs": {
"key_1": "value_1",
"key_2": "value_2"
}
}

Organization context

As part of the codexContext you can get information about the current organization the user is working on. When you access codexContext.organization you get the following result:

codexContext.organization
{
"id": "organizationId",
"name": "organizationName",
"alias": "organizationAlias", //usually same as id
"logo": "organizationLogoUrl",
"languageCode": "en", //undefined by default
"activePlugins": [
{
"id": "organizationPluginId",
"pluginName": "pluginName",
"pluginVersion": "1.0.0",
"path": "@/plugins/external/pluginName/1.0.0/"
}
]
}

Permissions context

As part of the codexContext you can get all the permissions of the current user in the current organization. When you access codexContext.userPermissions you get a dynamic object of the permissions the user has, including plugin permissions.

codexContext.userPermissions
{
"section_manage": true,
"list_manage": true,
"section_view": true,
"label_manage": true,
"sport_can_manage_matches": true
}