Skip to content

Commit 0cbc5b9

Browse files
committed
docs: add docs for the captcha plugin and adapters
1 parent 6515340 commit 0cbc5b9

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

adminforth/documentation/docs/tutorial/05-ListOfAdapters.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,24 @@ Pros:
186186
* Simplest in use - does not reqauire any external daemon.
187187
Cones:
188188
* In production sutable for single-process installations only
189+
190+
191+
## 🤖Captcha adapters
192+
193+
Used to add capthca to the login screen
194+
195+
[🔗Captcha adapter source class](https://github.com/devforth/adminforth/blob/65153408a119314dad339f452700e0937952034a/adminforth/types/adapters/CaptchaAdapter.ts#L5)
196+
197+
### Cloudflare adapter
198+
199+
```
200+
npm i @adminforth/login-captcha-adapter-cloudflare
201+
```
202+
203+
204+
### reCaptcha adapter
205+
206+
```
207+
npm i @adminforth/login-captcha-adapter-recaptcha
208+
```
209+
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Login Captcha
2+
3+
This plugin provides a captcha for the login page to enhance security.
4+
5+
## Installation
6+
7+
To install the plugin, run the following command:
8+
9+
```bash
10+
npm i @adminforth/login-captcha
11+
```
12+
13+
You will also need to install a captcha adapter. For example, to use the Cloudflare adapter, run:
14+
15+
```bash
16+
npm i @adminforth/login-captcha-adapter-cloudflare
17+
```
18+
19+
## Usage
20+
21+
To use the plugin, add it to your user resource file. Here's an example:
22+
23+
```ts template="./resources/adminuser.ts"
24+
// Import the plugin and adapter
25+
import CaptchaPlugin from "@adminforth/login-captcha";
26+
import CaptchaAdapterCloudflare from "@adminforth/captcha-adapter-cloudflare";
27+
28+
...
29+
30+
// Add the plugin to the `plugins` array
31+
plugins: [
32+
new CaptchaPlugin({
33+
captchaAdapter: new CaptchaAdapterCloudflare({
34+
siteKey: "YOUR_SITE_KEY", // Replace with your site key
35+
secretKey: "YOUR_SECRET_KEY", // Replace with your secret key
36+
}),
37+
}),
38+
]
39+
```
40+
41+
## Result
42+
43+
After setting up the plugin, your login page will include a captcha. Below is an example of how it will look:
44+
45+
![Login Captcha Example](LoginCaptcha1.png)
57.3 KB
Loading

0 commit comments

Comments
 (0)