# nestjs-ensureloggedin-guard

> NestJS Ensure Loggedin Guard

Latest version **1.1.2** (published 2019-01-20) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install nestjs-ensureloggedin-guard
pnpm add nestjs-ensureloggedin-guard
yarn add nestjs-ensureloggedin-guard
bun add nestjs-ensureloggedin-guard
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2019-01-20 |
| First published | 2018-07-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 39.2 KB |
| Known vulnerabilities | 0 (+4 in 3 direct dependencies) |
| Install scripts | no |
| Maintainers | gaurav-naik, revant |

## Links

- npm: https://www.npmjs.com/package/nestjs-ensureloggedin-guard
- npm.io page: https://npm.io/package/nestjs-ensureloggedin-guard

## Dependencies (6)

- [rxjs](https://npm.io/package/rxjs.md) ^6.2.1
- [passport](https://npm.io/package/passport.md) ^0.4.0
- [@nestjs/core](https://npm.io/package/@nestjs/core.md) ^5.6.2
- [@nestjs/common](https://npm.io/package/@nestjs/common.md) ^5.6.2
- [@nestjs/passport](https://npm.io/package/@nestjs/passport.md) ^5.1.0
- [reflect-metadata](https://npm.io/package/reflect-metadata.md) ^0.1.13

## Recent versions

- 1.1.2 (latest) — 2019-01-20
- 1.1.1 — 2019-01-07
- 1.1.0 — 2018-12-26
- 1.0.2 — 2018-07-27
- 1.0.1 — 2018-07-27

## README

# nestjs-ensureloggedin-guard

Revokes access to an endpoint if the user is does not have a valid session.

## Requirements

 * This package requires
   * [nestjs](https://nestjs.com/)
   * [passport](https://www.npmjs.com/package/passport)

## Install

```bash
npm i nestjs-ensureloggedin-guard
```

## Usage

Import the Guard in your controller.ts file.
```
import { EnsureLoginGuard } from 'nestjs-ensureloggedin-guard';
```

Add EnsureLoginGuard to the UseGuards decorator on the endpoint you want to restrict
```
@Get('myaccount')
@UseGuards(EnsureLoginGuard)
myaccount(@Req() req) {
    return { user: req.user ? req.user.email : 'Guest' };
}
```

## License

[MIT](http://vjpr.mit-license.org)

---
_Source: https://npm.io/package/nestjs-ensureloggedin-guard · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
