How to get currently logged in USERID in plugin?

Hi Chris,

So your server-side plugin should define an init method which accepts server as an argument. You can retrieve a getUser method exposed by X-Pack's security plugin at server.plugins.security.getUser. Then, whenever Hapi handles a request, you can call this method to get information about the user, like this:

const handleRequest = request  => {
    const getUser = server.plugins.security.getUser;
    const user = request;
};

Keep in mind that our plugin API is not stable, so it's very possible this will break without warning at some point in the future! I hope this helps.

Thanks,
CJ