# HOWTO access \`currentUser\` within the \`model()\` hook with ember-simple-auth?

**URL:** https://discuss.emberjs.com/t/howto-access-currentuser-within-the-model-hook-with-ember-simple-auth/13696
**Category:** Learning Team
**Created:** [October 4, 2017, 9:46am UTC](https://discuss.emberjs.com/t/howto-access-currentuser-within-the-model-hook-with-ember-simple-auth/13696 "2017-10-04T09:46:23Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![johnnyicon](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/johnnyicon/32/13390_2.png) [@johnnyicon](https://discuss.emberjs.com/u/johnnyicon)
#### Post date: [October 4, 2017, 9:46am UTC](https://discuss.emberjs.com/t/howto-access-currentuser-within-the-model-hook-with-ember-simple-auth/13696/1 "2017-10-04T09:46:24Z")

</div>

I am using `ember-simple-auth` as my authentication library.

I have a situation where I need to access the `currentUser`‘s ID to retrieve a record in the `model()` hook of a route handler. However, from what I understand, I’m not able to access the `session` service because it is injected into the controller, not into the route handler.

Is there a way to actually do this?

---

<div class="post-metadata">

### Author: ![Chris\_Lincoln](https://avatars.discourse-cdn.com/v4/letter/c/82dd89/32.png) [@Chris\_Lincoln](https://discuss.emberjs.com/u/Chris_Lincoln)
#### Post date: [October 4, 2017, 11:11am UTC](https://discuss.emberjs.com/t/howto-access-currentuser-within-the-model-hook-with-ember-simple-auth/13696/2 "2017-10-04T11:11:27Z")

</div>

You can inject it in the route like you would any other service. There is nothing special about it.

Also, somewhere in the simple-auth docs, there is a write-up called “managing current user” or something like that. It provides a basic cookbook for what you are attempting. We have been using that pattern successfully.

---

<div class="post-metadata">

### Author: ![johnnyicon](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/johnnyicon/32/13390_2.png) [@johnnyicon](https://discuss.emberjs.com/u/johnnyicon)
#### Post date: [October 4, 2017, 11:53am UTC](https://discuss.emberjs.com/t/howto-access-currentuser-within-the-model-hook-with-ember-simple-auth/13696/3 "2017-10-04T11:53:36Z")

</div>

Thanks, Chris! I’ll take a look.

---

<div class="post-metadata">

### Author: ![herzzanu](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/herzzanu/32/17850_2.png) [@herzzanu](https://discuss.emberjs.com/u/herzzanu)
#### Post date: [November 14, 2017, 6:23am UTC](https://discuss.emberjs.com/t/howto-access-currentuser-within-the-model-hook-with-ember-simple-auth/13696/4 "2017-11-14T06:23:47Z")

</div>

@johnnyicon you can create the `currentUser` service as explained in the docs [ESA - Managing a Current User](https://github.com/simplabs/ember-simple-auth/blob/master/guides/managing-current-user.md)

and then just use it in your route like this, given you want to get all the bookings of the current user in the following example:

```auto
import Ember from 'ember';

const { inject: { service } } = Ember;

export default Ember.Route.extend({
  currentUser: service(),
    
  model() {
    let userId = this.get('currentUser.user.id');
    return this.store.query('booking', { user_id: userId });
  }
});
```
