# loopback-component-current-user

> get the current user from access token for Loopback.

Latest version **0.1.2** (published 2016-05-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install loopback-component-current-user
pnpm add loopback-component-current-user
yarn add loopback-component-current-user
bun add loopback-component-current-user
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2016-05-28 |
| First published | 2016-05-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Riceball LEE |
| Maintainers | riceball |
| Keywords | loopback, strongloop, user, current user |

## Links

- npm: https://www.npmjs.com/package/loopback-component-current-user
- Repository: https://github.com/snowyu/loopback-component-current-user
- Issues: https://github.com/snowyu/loopback-component-current-user/issues
- npm.io page: https://npm.io/package/loopback-component-current-user

## Dependencies (2)

- [debug](https://npm.io/package/debug.md) ^2.2.0
- [bluebird](https://npm.io/package/bluebird.md) ^3.4.0

## Recent versions

- 0.1.2 (latest) — 2016-05-28
- 0.1.1 — 2016-05-28
- 0.1.0 — 2016-05-28

## README

# Loopback Component Current User

This loopback component enables you to add the logined(current) user to the request of thhe loopback application.

### Installation

1. Install in you loopback project:

  `npm install --save loopback-component-current-user`

2. Create a component-config.json file in your server folder (if you don't already have one)

3. Configure options inside `component-config.json`:

  ```json
  {
    "loopback-component-current-user": {
      "user": "User"
    }
  }
  ```
  - `user`
    * [String] : The name of the user model. *(default: 'User')*


4. Create a middleware.json file in your server folder (if you don't already have one).

5. Ensure that you enable the `loopback#token` middleware early in your middleware chain.

  ```json
  {
    "initial:before": {
      "loopback#token": {}
    },
  }
  ```

### Usage

```js

Model.beforeRemote('*', function(ctx, next){
  console.log(ctx.req.currentUser)
})

```

---
_Source: https://npm.io/package/loopback-component-current-user · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
