Skip to content

Commit 4986c8b

Browse files
committed
Merge branch 'main' of github.com:devforth/adminforth
2 parents 72a9cbe + c624c4e commit 4986c8b

1 file changed

Lines changed: 19 additions & 14 deletions

File tree

adminforth/documentation/docs/tutorial/09-Plugins/07-email-password-reset.md

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@ Plugin allows to reset password for admin users who forgot their password by sen
1616
Installation:
1717

1818
```bash
19-
pnpm install @adminforth/email-password-reset --save
20-
pnpm install @adminforth/email-adapter-aws-ses --save
19+
pnpm add @adminforth/email-password-reset
20+
pnpm add @adminforth/email-adapter-aws-ses
21+
pnpm add @adminforth/key-value-adapter-ram
2122
```
2223

24+
>⚠️Note: we use key/value adapter to store used password reset token for validity period and we recomend to use stateful adapter like Redis in production, because stateless adapter (like key/value RAM) is cleared after server restart and password reset token could be re-used for the second time
25+
2326
Import plugin:
2427

2528
```typescript
@@ -42,6 +45,8 @@ Add plugin to user resource:
4245
```typescript ./resources/adminuser.ts
4346
import EmailResetPasswordPlugin from '@adminforth/email-password-reset';
4447
import EmailAdapterAwsSes from '@adminforth/email-adapter-aws-ses';
48+
import KeyValueAdapterRam from '@adminforth/key-value-adapter-ram';
49+
4550
...
4651
plugins: [
4752
...
@@ -56,12 +61,12 @@ plugins: [
5661
sendFrom: 'no-reply@devforth.io',
5762

5863
adapter: new EmailAdapterAwsSes({
59-
// region where SES is setup
60-
region: "eu-central-1",
61-
accessKeyId: process.env.AWS_ACCESS_KEY_ID as string,
62-
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY as string,
63-
}),
64-
64+
// region where SES is setup
65+
region: "eu-central-1",
66+
accessKeyId: process.env.AWS_ACCESS_KEY_ID as string,
67+
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY as string,
68+
}),
69+
userResetTokensKeyValueAdapter: new KeyValueAdapterRam(),
6570
}),
6671
]
6772
```
@@ -102,12 +107,12 @@ plugins: [
102107
sendFrom: 'no-reply@devforth.io',
103108

104109
adapter: new EmailAdapterMailgun({
105-
apiKey: process.env.MAILGUN_API_KEY as string,
106-
domain: process.env.MAILGUN_DOMAIN as string,
107-
//baseUrl is optional, if not provided, will default to "https://api.mailgun.net" but if you are using Mailgun EU, you should use "https://api.eu.mailgun.net" instead
108-
baseUrl: process.env.MAILGUN_REGION_URL as string,
109-
}),
110-
110+
apiKey: process.env.MAILGUN_API_KEY as string,
111+
domain: process.env.MAILGUN_DOMAIN as string,
112+
//baseUrl is optional, if not provided, will default to "https://api.mailgun.net" but if you are using Mailgun EU, you should use "https://api.eu.mailgun.net" instead
113+
baseUrl: process.env.MAILGUN_REGION_URL as string,
114+
}),
115+
userResetTokensKeyValueAdapter: new KeyValueAdapterRam(),
111116
}),
112117
]
113118
```

0 commit comments

Comments
 (0)