@webbio/strapi-plugin-page-builder 0.16.0-platform → 0.17.1-platform

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webbio/strapi-plugin-page-builder",
3
- "version": "0.16.0-platform",
3
+ "version": "0.17.1-platform",
4
4
  "description": "This is the description of the plugin.",
5
5
  "scripts": {
6
6
  "develop": "tsc -p tsconfig.server.json -w",
@@ -77,9 +77,11 @@ export default async ({ strapi }: { strapi: Strapi }) => {
77
77
  models: [PAGE_UID],
78
78
  async beforeCreate(event) {
79
79
  let { data } = event.params;
80
+
80
81
  const collectionTypeId = data?.collectionTypeId;
81
- const pageTypeId = data?.pageType.connect?.[0]?.id || data.initialPageType;
82
- const platformId = data?.platform.connect?.[0]?.id;
82
+
83
+ const pageTypeId = data?.pageType?.connect?.[0]?.id || data.initialPageType;
84
+ const platformId = data?.platform?.connect?.[0]?.id;
83
85
 
84
86
  if (collectionTypeId && pageTypeId) {
85
87
  const pageType: Record<string, any> | undefined | null = await strapi.entityService?.findOne(
@@ -90,7 +90,7 @@ export const extendControllers = () => {
90
90
  const { user: admin, userAbility } = ctx.state;
91
91
 
92
92
  const { email } = body;
93
- const platformId = body.platform.connect[0].id;
93
+ const platformId = body?.platform?.connect?.[0]?.id;
94
94
 
95
95
  const pm = strapi?.admin?.services.permission.createPermissionsManager({
96
96
  ability: userAbility,
@@ -123,7 +123,7 @@ export const extendControllers = () => {
123
123
 
124
124
  const advanced = await strapi?.store({ type: 'plugin', name: 'users-permissions', key: 'advanced' }).get({});
125
125
 
126
- if (user.role.connect.length === 0) {
126
+ if ((user?.role?.connect?.length || 0) === 0) {
127
127
  //@ts-ignore strapi types...
128
128
  const defaultRole = await strapi.query(USER_ROLE).findOne({ where: { type: advanced.default_role } });
129
129
  user.role = defaultRole.id;
@@ -148,7 +148,7 @@ export const extendControllers = () => {
148
148
  const { pm, entity } = await findEntityAndCheckPermissions(userAbility, ACTIONS.edit, USER_MODEL, id);
149
149
  const user = entity;
150
150
 
151
- const platformId = body.platform.connect.length > 0 ? body.platform.connect[0].id : entity.platform.id;
151
+ const platformId = (body?.platform?.connect?.length || 0) > 0 ? body.platform.connect[0].id : entity.platform.id;
152
152
 
153
153
  if (has(body, 'password') && !password && user.provider === 'local') {
154
154
  throw new ValidationError('password.notNull');