System Information
- Strapi Version: 4.22.1
- Operating System: Mac M1
- Database: sq-lite
- Node Version: 18
- NPM Version: 9
- Yarn Version:
I have a custom plugin, built with React.
Inside that plugin (src/plugins/myPlugin/admin/pages/App.js), I want to be able to get some context about the logged in user.
Throughs some trial and error (aka guessing), I was able to get
appInfo.userDisplayName and
appInfo.userId
I’ve tried console logging every hook exported by “@strapi/helper-plugin”, but nothing else provided useful information.
But I would like more information. Specifically, I would like to get the user’s Role type, so that my custom plugin can display a slightly different view for Admin vs Author vs Guests.
// src/plugins/myPlugin/admin/pages/App.js
import {useAppInfo} from "@strapi/helper-plugin";
const App = (props) => {
const appInfo = useAppInfo()
console.log(appInfo.userDisplayName)
console.log(appInfo.userId)
console.log(props) // empty object. Can I inject ctx in here somehow?
return (
...
)
}
How can I access the user’s email and role type in my React App.js, for a custom plugin?
Is it possible? It’s not available in the useAppInfo hook. I doubt it’s available in any other hook. How can I inject this context into my App.js?