Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add custom role type and validation #27

Merged

Conversation

BibiSebi
Copy link
Contributor

@BibiSebi BibiSebi commented Sep 21, 2023

Issue:
EXT-2001

What?

Users with custom roles are being redirected to the errorCallback page. This is an unexpected behavior.

Here a reference for better understaning:

  1. Response from /oauth/user_info with the backed-in storyblok role (admin or editor)
{
    "user": {
        "id": 123,
        "friendly_name": "Bibiana"
    },
    "space": {
        "id": 1234,
        "name": "Test"
    },
    "roles": [
        {
            "name": "admin"
        }
    ]
}
  1. Response from /oauth/user_info with a custom role user:
{
    "user": {
        "id": 123,
        "friendly_name": "Bibiana"
    },
    "space": {
        "id": 1234,
        "name": "Test"
    },
    "roles": [
        {
            "id": 1,
            "resolved_allowed_paths": [],
            "allowed_paths": [],
            "field_permissions": [],
            "readonly_field_permissions": [],
            "permissions": [],
            "role": "Developer",
            "subtitle": null,
            "datasource_ids": [],
            "component_ids": [],
            "branch_ids": [],
            "allowed_languages": [],
            "asset_folder_ids": [],
            "ext_id": null
        },
    ],
}

The problem happens when validating the role object:

const isRole = (obj) => 'name' in obj && typeof obj.name === 'string'

As the custom role has no nameproperty this validation fails.

Support Ticket: EXT-2001

@BibiSebi BibiSebi requested a review from eunjae-lee September 21, 2023 07:43
Copy link
Contributor

@eunjae-lee eunjae-lee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a wrong understanding of this issue yesterday. Now I see what you mean. Looks good!

@BibiSebi BibiSebi merged commit b46f79c into main Sep 21, 2023
@BibiSebi BibiSebi deleted the EXT-2001-broken-links-checker-only-admins-can-run-checks branch September 21, 2023 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants