1.1.2 • Published 5 years ago

nestjs-ensureloggedin-guard v1.1.2

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

nestjs-ensureloggedin-guard

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

Requirements

Install

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