# How to get currently logged in USERID in plugin?

**URL:** https://discuss.elastic.co/t/how-to-get-currently-logged-in-userid-in-plugin/58627
**Category:** Kibana
**Created:** [August 22, 2016, 9:55pm UTC](https://discuss.elastic.co/t/how-to-get-currently-logged-in-userid-in-plugin/58627 "2016-08-22T21:55:08Z")
**Posts on this page:** 1
**Showing post:** 8

<div class="post-metadata">

### Author: ![cjcenizal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cjcenizal/32/11216_2.png) [@cjcenizal](https://discuss.elastic.co/u/cjcenizal)
#### Post date: [April 17, 2017, 10:51pm UTC](https://discuss.elastic.co/t/how-to-get-currently-logged-in-userid-in-plugin/58627/8 "2017-04-17T22:51:47Z")

</div>

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:

```auto
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

---

_[View the full topic](https://discuss.elastic.co/t/how-to-get-currently-logged-in-userid-in-plugin/58627)._
