ra-data-feathers
ra-data-feathers copied to clipboard
Disccussion about Permission
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.
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.