@webbio/strapi-plugin-page-builder 0.12.8-platform → 0.13.0-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.12.8-platform",
3
+ "version": "0.13.0-platform",
4
4
  "description": "This is the description of the plugin.",
5
5
  "scripts": {
6
6
  "develop": "tsc -p tsconfig.server.json -w",
@@ -33,27 +33,31 @@ export default async ({ strapi }: { strapi: Strapi }) => {
33
33
  populate: '*'
34
34
  })) as Record<string, any>[];
35
35
 
36
- // checks which role the user has
37
- const foundRole = roles.filter((role) => {
38
- return x.roles.find((userRole) => userRole.name === role.name);
39
- });
36
+ // checks which roles the user has
37
+ const foundRoles = roles.filter((role) => x.roles.find((userRole) => userRole.name === role.name));
38
+
39
+ // Get all permissions from the roles the user has
40
+ const allPermissions = [foundRoles?.[0]]
41
+ .map((role) => role?.permissions)
42
+ .flat()
43
+ .filter(Boolean);
40
44
 
41
45
  // get the right platform permissions, and filters out the platform
42
46
  // this is neccesary because of multiple platforms. if you can see Vacancy from platform 1 and collegue from platform 2
43
47
  // it will show both at page level, so this filters out the wrong page
44
- const platformPermission = foundRole?.[0]?.permissions.map((permission) => {
45
- return {
46
- permission: permission.subject,
47
- condition: permission.conditions.filter((condition) => condition.includes(platform.title))
48
- };
49
- });
50
-
51
- // get the right permission for platform
52
- const permissions = platformPermission.map((permission) => {
53
- if (permission.condition.length > 0) {
54
- return permission.permission;
55
- }
56
- });
48
+ const platformPermission = allPermissions.map((permission) => ({
49
+ subject: permission.subject,
50
+ conditions: permission?.conditions.filter((condition) => condition.includes(platform.title))
51
+ }));
52
+
53
+ // Get the right permission for platform
54
+ const permissions = platformPermission
55
+ .map((permission) => {
56
+ if (permission.conditions.length > 0) {
57
+ return permission.subject;
58
+ }
59
+ })
60
+ .filter(Boolean);
57
61
 
58
62
  const uniquePermissions = uniq(permissions);
59
63
 
@@ -7,7 +7,7 @@ export default {
7
7
  const callbackUrl = `${user.platform.domain}/inloggen`;
8
8
  return ctx.redirect(callbackUrl);
9
9
  } catch (error) {
10
- console.log(ctx);
10
+ console.log('Activate User Error', error, ctx);
11
11
  return ctx.unauthorized('User is already confirmed or token is invalid');
12
12
  }
13
13
  },