Skip to content
This repository has been archived by the owner on Jul 25, 2024. It is now read-only.

Commit

Permalink
feat (package): added configurable instructions command to setup JWT …
Browse files Browse the repository at this point in the history
…in a project
  • Loading branch information
maxgalbu committed Oct 20, 2021
1 parent 0c2c014 commit 73ad005
Show file tree
Hide file tree
Showing 7 changed files with 1,617 additions and 245 deletions.
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"printWidth": 120
}
36 changes: 13 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,21 @@ Add JWT authentication to Adonisjs v5.

## Installation

Install via `npm` or `yarn`:
Make sure to install and configure `@adonisjs/auth` and `@adonisjs/lucid` beforehand, by running the following commands:

```js
npm install @adonisjs/auth @adonisjs/lucid
//Or, with yarn: yarn add @adonisjs/auth @adonisjs/lucid

node ace configure @adonisjs/auth
node ace configure @adonisjs/lucid
```

Install `adonis5-jwt` via `npm` or `yarn`:

```js
npm install adonis5-jwt
//Or if you use yarn
yarn add adonis5-jwt
//Or, with yarn: yarn add adonis5-jwt
```

After the package has been installed, you have to configure it by running a command:
Expand All @@ -20,26 +29,7 @@ After the package has been installed, you have to configure it by running a comm
node ace configure adonis5-jwt
```

Then, edit `contracts/auth.ts` like this:

```ts
//Add the following line
import { JWTGuardConfig, JWTGuardContract } from "@ioc:Adonisjs/Addons/Jwt";

declare module '@ioc:Adonis/Addons/Auth' {
...

interface GuardsList {
...other guards...

//Add the following lines and change 'user' to whatever Provider you're using
jwt: {
implementation: JWTGuardContract<'user', 'jwt'>,
config: JWTGuardConfig<'user'>,
}
}
}
```
This will ask a few questions and modify adonisjs files accordingly.

## Usage

Expand Down
28 changes: 0 additions & 28 deletions instructions.md

This file was deleted.

Loading

0 comments on commit 73ad005

Please sign in to comment.