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

Disccussion about Permission #168

Open
tanedward2101 opened this issue Aug 25, 2021 · 1 comment
Open

Disccussion about Permission #168

tanedward2101 opened this issue Aug 25, 2021 · 1 comment

Comments

@tanedward2101
Copy link

tanedward2101 commented Aug 25, 2021

Hi, need some help here.
My authentication feathers return this.

{
    "accessToken": "",
    "authentication": {
        "strategy": "local",
        "accessToken": "",
        "payload": {

        }
    },
    "user": {
        "id": 10,
        "username": "John Doe",
        "roles": [
            "administrator",
            "another-role"
        ],
    }
}

And this is my authClientOption

const authClientOptions = {
  storageKey: 'feathers-jwt', // The key in localStorage used to store the authentication token
  authenticate: { // Options included in calls to Feathers client.authenticate
    strategy: 'local',
  },
  permissionsKey: 'permissions', // The key in localStorage used to store permissions from decoded JWT
  permissionsField: 'roles', // The key in the decoded JWT containing the user's role
  passwordField: 'password', // The key used to provide the password to Feathers client.authenticate
  usernameField: 'username', // The key used to provide the username to Feathers client.authenticate
  redirectTo: '/login', // Redirect to this path if an AUTH_CHECK fails. Uses the react-admin default of '/login' if omitted.
  logoutOnForbidden: true
};

One user can have multiple roles. Is there anyway to get that roles data?
Somehow, I cannot retrieve roles data.

@josx
Copy link
Owner

josx commented Aug 26, 2021

Permissions seems to be an array. Please check permissions content.

Anyway check react-admin auth doc: https://marmelab.com/react-admin/Authorization.html
Exists usePermissions() hook, you can use it.

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

No branches or pull requests

2 participants