Skip to content

Commit 8212d06

Browse files
authored
Merge branch 'main' into next
2 parents dd4708c + 6707552 commit 8212d06

File tree

11 files changed

+416
-568
lines changed

11 files changed

+416
-568
lines changed

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# AdminForth - fully free Node.js admin panel framework on Vue & Tailwind
1+
# AdminForth - free powerfull Node.js admin panel framework on Vue & Tailwind
22

33

44
<a href="https://adminforth.dev"><img src="https://img.shields.io/badge/website-adminforth.dev-blue" style="height:24px"/></a> <a href="https://adminforth.dev"><img src="https://img.shields.io/npm/dw/adminforth" style="height:24px"/></a> <a href="https://devforth.io"><img src="https://raw.githubusercontent.com/devforth/OnLogs/e97944fffc24fec0ce2347b205c9bda3be8de5c5/.assets/df_powered_by.svg" style="height:28px"/></a>
@@ -20,12 +20,15 @@
2020
<br/>
2121

2222
Why AdminForth:
23-
* AdminForth is always free and open-source (no paid versions, no cloud subscriptions sh*t)
24-
* Init AdminForth with your database URL in Node.js file, easily describe the tables you wish to see in admin, and get fully functional UI for your data (filter, create, edit, remove)
25-
* Define Vue components to change look of various parts of admin (place in data cell, instead of row, add something above the table, inject something to header or sidebar, add custom page with charts or custom components)
26-
* Rich build-in Components library (AdminForth AFCL) with premade easy-to-use build-blocks which follow your theme
23+
24+
* Init AdminForth project with `npx adminforth create-app` and pass your database URL, import the tables you wish to see in admin using `npx adminforth resource`, and get fully functional UI for your data (filter, create, edit, remove)
25+
* Modern look and simple Tailwind-ish ability to adjust it
26+
* Supports Postgres, MySQL, Mongo, SQLite, Clickhouse
27+
* Define Vue components to change look of various parts of admin using `npx adminforth component` (edit data cells, edit fields, add something above the table, inject something to header or sidebar, add custom page with charts or custom components)
28+
* Build-in Components library (AdminForth AFCL) with premade easy-to-use build-blocks which follow your theme
2729
* Define express APIs and call them from your components and pages
28-
* Use various modern back-office-must-have plugins like audit log, files/image upload, TOTP 2FA, I18N, Copilot-style AI writing and image generation
30+
* Use various modern back-office-must-have plugins like audit log, files/image upload, TOTP 2FA, I18N, Copilot-style AI writing and image generation and many more
31+
* AdminForth is always free and open-source (no paid versions, no cloud subscriptions sh*t)
2932

3033

3134
## Project initialisation
@@ -117,4 +120,4 @@ Then, go to testing app, e.g. created with CLI, and use next command:
117120
npx -g adminforth <your command under development>
118121
```
119122

120-
This will always run latest version of adminforth package.
123+
This will always run latest version of adminforth package.

adminforth/documentation/blog/authors.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ivanb:
44
url: https://github.com/ivictbor
55
image_url: https://avatars.githubusercontent.com/u/1838656?v=4
66
mpipkun:
7-
name: Maxim Pypkun
7+
name: Maksym Pipkun
88
title: Developer of AdminForth
99
url: https://github.com/NoOne7135
1010
image_url: https://avatars.githubusercontent.com/u/120279695?v=4
@@ -22,4 +22,4 @@ kirilldorr:
2222
name: Kyrylo Doropii
2323
title: DevOps Engineer of AdminForth
2424
url: https://github.com/kirilldorr
25-
image_url: https://avatars.githubusercontent.com/u/181721742?s=96&v=4
25+
image_url: https://avatars.githubusercontent.com/u/181721742?s=96&v=4
Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
# Email Invite
2+
3+
Email Invite plugin allows administrators to create users without setting passwords. Instead, the plugin sends an email invitation to the newly created user, asking them to set their own password. This is more secure and user-friendly than having administrators set passwords for users.
4+
5+
## Installation
6+
7+
To install the plugin:
8+
9+
```bash
10+
npm install @adminforth/email-invite --save
11+
```
12+
13+
You'll also need an email adapter. For AWS SES:
14+
15+
```bash
16+
npm install @adminforth/email-adapter-aws-ses --save
17+
```
18+
19+
## SES
20+
21+
To Setup SES, you need to have an AWS account and SES service enabled. You can follow the steps below to setup SES.
22+
23+
1. Go to the AWS Management Console and open the Amazon SES console at [https://console.aws.amazon.com/ses/](https://console.aws.amazon.com/ses/).
24+
2. Make sure you are in the correct region. You can change the region from the top right corner. For example, if you are in the `us-east-1` region, you can see the region name US East (N. Virginia) in the top right corner.
25+
26+
3. Add your email address (any email), and verify it.
27+
4. Add some domain you own and verify it by creating DNS records which AWS suggests. This will be used as the domain for sending emails. e.g. if you want to send from [email protected] you need to verify `devforth.io`.
28+
29+
## Basic Usage
30+
31+
```typescript title="./resources/adminuser.ts"
32+
import EmailInvitePlugin from '@adminforth/email-invite';
33+
import EmailAdapterAwsSes from '@adminforth/email-adapter-aws-ses';
34+
35+
export default {
36+
dataSource: 'maindb',
37+
table: 'adminuser',
38+
resourceId: 'adminuser',
39+
columns: [
40+
{ name: 'id', primaryKey: true },
41+
{ name: 'email', required: true },
42+
{ name: 'password_hash', showIn: [] }, // Hide from UI
43+
44+
{ name: 'role' },
45+
46+
{
47+
name: 'password',
48+
virtual: true,
49+
required: { create: true },
50+
editingNote: { edit: 'Leave empty to keep password unchanged' },
51+
minLength: 8,
52+
type: AdminForthDataTypes.STRING,
53+
showIn: {
54+
// hide password column - but don't remove whole column it because it has constrains for password field!
55+
// diff-remove
56+
show: false,
57+
// diff-remove
58+
list: false,
59+
// diff-remove
60+
filter: false,
61+
// diff-add
62+
all: false,
63+
},
64+
masked: true,
65+
},
66+
67+
// ... other columns
68+
],
69+
hooks: {
70+
create: {
71+
beforeSave: async ({ record, adminUser, resource }: { record: any, adminUser: AdminUser, resource: AdminForthResource }) => {
72+
// since we don't show password input in resource - no sense to hande it in hook anymore!
73+
//diff-remove
74+
record.password_hash = await AdminForth.Utils.generatePasswordHash(record.password);
75+
return { ok: true };
76+
}
77+
},
78+
edit: {
79+
beforeSave: async ({ oldRecord, updates, adminUser, resource }: { oldRecord: any, updates: any, adminUser: AdminUser, resource: AdminForthResource }) => {
80+
console.log('Updating user', updates);
81+
if (oldRecord.id === adminUser.dbUser.id && updates.role) {
82+
return { ok: false, error: 'You cannot change your own role' };
83+
}
84+
// also no sense to have updatres - we dont allow edit password by admin anymore
85+
//diff-remove
86+
if (updates.password) {
87+
//diff-remove
88+
updates.password_hash = await AdminForth.Utils.generatePasswordHash(updates.password);
89+
//diff-remove
90+
}
91+
return { ok: true }
92+
},
93+
},
94+
},
95+
plugins: [
96+
new EmailInvitePlugin({
97+
emailField: 'email',
98+
sendFrom: '[email protected]',
99+
adapter: new EmailAdapterAwsSes({
100+
region: 'us-east-1',
101+
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
102+
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
103+
}),
104+
}),
105+
],
106+
};
107+
```
108+
109+
Please note that previously (in defauklt CLI setup) we needed it to allow admins to set passwords when created new users (to invite them). Also Admens were able to edit passwords of users.
110+
Now since we added this plugin, user will have email link on which he will get form to enter password by hiumself.
111+
Please note that the form for user will still use constraints from password virtual field, that is why we just hid it using showIn - not remove it.
112+
113+
To allow users to edit their passwords please use [email password reset plugin](https://adminforth.dev/docs/tutorial/Plugins/email-password-reset/)
114+
115+
## Email Confirmation boolean flag
116+
117+
This plugin can write into the database the fact that invited user was able to set password and as a result confirmed that he owns his email.
118+
To enable email this behaviour, first add a boolean field to your user table:
119+
120+
```prisma title="./schema.prisma"
121+
model adminuser {
122+
id String @id @default(cuid())
123+
email String @unique
124+
password_hash String
125+
role String @default("user")
126+
//diff-add
127+
email_confirmed Boolean? @default(false)
128+
// ... other fields
129+
}
130+
```
131+
132+
Run the migration:
133+
134+
```bash
135+
npx prisma migrate dev --name add-email-confirmed
136+
```
137+
138+
Then update your resource configuration:
139+
140+
```typescript title="./resources/adminuser.ts"
141+
export default {
142+
// ... existing config
143+
columns: [
144+
{ name: 'id', primaryKey: true },
145+
{ name: 'email', required: true },
146+
{ name: 'password_hash', showIn: [] },
147+
{ name: 'role' },
148+
//diff-add
149+
{ name: 'email_confirmed', type: AdminForthDataTypes.BOOLEAN },
150+
// ... other columns
151+
],
152+
plugins: [
153+
new EmailInvitePlugin({
154+
emailField: 'email',
155+
sendFrom: '[email protected]',
156+
adapter: new EmailAdapterAwsSes(/* ... */),
157+
//diff-add
158+
emailConfirmedField: 'email_confirmed', // Enable email confirmation
159+
}),
160+
],
161+
};
162+
```
163+

0 commit comments

Comments
 (0)