diff --git a/adminforth/commands/createApp/templates/users.ts.hbs b/adminforth/commands/createApp/templates/adminuser.ts.hbs similarity index 98% rename from adminforth/commands/createApp/templates/users.ts.hbs rename to adminforth/commands/createApp/templates/adminuser.ts.hbs index a26d3688b..2087b54f7 100644 --- a/adminforth/commands/createApp/templates/users.ts.hbs +++ b/adminforth/commands/createApp/templates/adminuser.ts.hbs @@ -8,7 +8,7 @@ async function canModifyUsers({ adminUser }: { adminUser: AdminUser }): Promise< export default { dataSource: 'maindb', table: 'adminuser', - resourceId: 'users', + resourceId: 'adminuser', label: 'Users', recordLabel: (r) => `πŸ‘€ ${r.email}`, options: { @@ -44,7 +44,7 @@ export default { { name: 'created_at', type: AdminForthDataTypes.DATETIME, - showIn: [{ + showIn: { edit: false, create: false, }, diff --git a/adminforth/commands/createApp/templates/index.ts.hbs b/adminforth/commands/createApp/templates/index.ts.hbs index 9df5ac9f1..fb0fa24a6 100644 --- a/adminforth/commands/createApp/templates/index.ts.hbs +++ b/adminforth/commands/createApp/templates/index.ts.hbs @@ -1,13 +1,13 @@ import express from 'express'; import AdminForth, { Filters } from 'adminforth'; -import usersResource from "./resources/users"; +import usersResource from "./resources/adminuser"; const ADMIN_BASE_URL = ''; export const admin = new AdminForth({ baseUrl: ADMIN_BASE_URL, auth: { - usersResourceId: 'users', + usersResourceId: 'adminuser', usernameField: 'email', passwordHashField: 'password_hash', rememberMeDays: 30, @@ -51,7 +51,7 @@ export const admin = new AdminForth({ { label: 'Users', icon: 'flowbite:user-solid', - resourceId: 'users' + resourceId: 'adminuser' } ], }); @@ -68,8 +68,8 @@ if (import.meta.url === `file://${process.argv[1]}`) { admin.express.serve(app) admin.discoverDatabases().then(async () => { - if (!await admin.resource('users').get([Filters.EQ('email', 'adminforth')])) { - await admin.resource('users').create({ + if (!await admin.resource('adminuser').get([Filters.EQ('email', 'adminforth')])) { + await admin.resource('adminuser').create({ email: 'adminforth', password_hash: await AdminForth.Utils.generatePasswordHash('adminforth'), role: 'superadmin', diff --git a/adminforth/commands/createApp/utils.js b/adminforth/commands/createApp/utils.js index b22986a2c..85774eedf 100644 --- a/adminforth/commands/createApp/utils.js +++ b/adminforth/commands/createApp/utils.js @@ -191,8 +191,8 @@ async function writeTemplateFiles(dirname, cwd, options) { data: { dbUrl, prismaDbUrl }, }, { - src: 'users.ts.hbs', - dest: 'resources/users.ts', + src: 'adminuser.ts.hbs', + dest: 'resources/adminuser.ts', data: {}, }, { diff --git a/adminforth/documentation/blog/2024-10-01-ai-blog/index.md b/adminforth/documentation/blog/2024-10-01-ai-blog/index.md index 537d96e6b..40ce04ef4 100644 --- a/adminforth/documentation/blog/2024-10-01-ai-blog/index.md +++ b/adminforth/documentation/blog/2024-10-01-ai-blog/index.md @@ -207,7 +207,7 @@ declare var process : { export const admin = new AdminForth({ baseUrl: '/admin', auth: { - usersResourceId: 'user', // resource to get user during login + usersResourceId: 'adminuser', // resource to get user during login usernameField: 'email', // field where username is stored, should exist in resource passwordHashField: 'passwordHash', }, @@ -249,7 +249,7 @@ export const admin = new AdminForth({ { label: 'Users', icon: 'flowbite:user-solid', - resourceId: 'user', + resourceId: 'adminuser', } ], }); @@ -278,7 +278,7 @@ if (import.meta.url === `file://${process.argv[1]}`) { Sorts.DESC('createdAt'), ); const authorIds = [...new Set(posts.map((p: any) => p.authorId))]; - const authors = (await admin.resource('user').list(Filters.IN('id', authorIds))) + const authors = (await admin.resource('adminuser').list(Filters.IN('id', authorIds))) .reduce((acc: any, a: any) => {acc[a.id] = a; return acc;}, {}); posts.forEach((p: any) => { const author = authors[p.authorId]; @@ -309,8 +309,8 @@ if (import.meta.url === `file://${process.argv[1]}`) { admin.express.serve(app) admin.discoverDatabases().then(async () => { - if (!await admin.resource('user').get([Filters.EQ('email', 'adminforth@adminforth.dev')])) { - await admin.resource('user').create({ + if (!await admin.resource('adminuser').get([Filters.EQ('email', 'adminforth@adminforth.dev')])) { + await admin.resource('adminuser').create({ email: 'adminforth@adminforth.dev', passwordHash: await AdminForth.Utils.generatePasswordHash('adminforth'), }); @@ -325,16 +325,16 @@ if (import.meta.url === `file://${process.argv[1]}`) { ## Step 5: Create resources -Create `res` folder. Create `./res/user.ts` file with following content: +Create `res` folder. Create `./res/adminuser.ts` file with following content: -```ts title="./res/users.ts" +```ts title="./res/adminuser.ts" import AdminForth, { AdminForthDataTypes } from 'adminforth'; import { randomUUID } from 'crypto'; import UploadPlugin from '@adminforth/upload'; export default { dataSource: 'maindb', - table: 'user', + table: 'adminuser', label: 'Users', recordLabel: (r: any) => `πŸ‘€ ${r.email}`, columns: [ @@ -501,7 +501,7 @@ export default { { name: 'authorId', foreignResource: { - resourceId: 'user', + resourceId: 'adminuser', }, showIn: { list: false, diff --git a/adminforth/documentation/docs/tutorial/001-gettingStarted.md b/adminforth/documentation/docs/tutorial/001-gettingStarted.md index 4b5b45ff2..91c88e5fd 100644 --- a/adminforth/documentation/docs/tutorial/001-gettingStarted.md +++ b/adminforth/documentation/docs/tutorial/001-gettingStarted.md @@ -64,7 +64,7 @@ myadmin/ β”‚ β”œβ”€β”€ package.json # For any custom npm packages you will use in Vue files β”‚ └── tsconfig.json # Tsconfig for Vue project (adds completion for AdminForth core components) β”œβ”€β”€ resources -β”‚ └── users.ts # Example resource file for users management +β”‚ └── adminuser.ts # Example resource file for users management β”œβ”€β”€ schema.prisma # Prisma schema file for database schema β”œβ”€β”€ index.ts # Main entry point: configures AdminForth & starts the server β”œβ”€β”€ package.json # Project dependencies @@ -128,7 +128,7 @@ Also in AdminForth you can define in "Vue" way: ## Adding an `apartments` Model -So far, our freshly generated AdminForth project includes a default `adminuser` model and a corresponding `users` resource. +So far, our freshly generated AdminForth project includes a default `adminuser` model and a corresponding `adminuser` resource. Let’s expand our app to suport managment of **`apartments`** model. Adding new resource will involve next steps: @@ -294,7 +294,7 @@ export default { { name: 'realtor_id', foreignResource: { - resourceId: 'users', + resourceId: 'adminuser', } } ], @@ -417,8 +417,8 @@ if (import.meta.url === `file://${process.argv[1]}`) { ... admin.discoverDatabases().then(async () => { - if (!await admin.resource('users').get([Filters.EQ('email', 'adminforth')])) { - await admin.resource('users').create({ + if (!await admin.resource('adminuser').get([Filters.EQ('email', 'adminforth')])) { + await admin.resource('adminuser').create({ email: 'adminforth', password_hash: await AdminForth.Utils.generatePasswordHash('adminforth'), role: 'superadmin', diff --git a/adminforth/documentation/docs/tutorial/01-helloWorld.md b/adminforth/documentation/docs/tutorial/01-helloWorld.md index 3a74fa6ca..b9a3c0bc4 100644 --- a/adminforth/documentation/docs/tutorial/01-helloWorld.md +++ b/adminforth/documentation/docs/tutorial/01-helloWorld.md @@ -126,7 +126,7 @@ import AdminForth, { AdminForthDataTypes, AdminUser, Filters } from 'adminforth' export const admin = new AdminForth({ baseUrl: '', auth: { - usersResourceId: 'users', // resource to get user during login + usersResourceId: 'adminuser', // resource to get user during login usernameField: 'email', // field where username is stored, should exist in resource passwordHashField: 'passwordHash', }, @@ -143,8 +143,8 @@ export const admin = new AdminForth({ resources: [ { dataSource: 'maindb', - table: 'user', - resourceId: 'users', + table: 'adminuser', + resourceId: 'adminuser', label: 'Users', recordLabel: (r: any) => `πŸ‘€ ${r.email}`, columns: [ @@ -242,7 +242,7 @@ export const admin = new AdminForth({ { name: 'authorId', foreignResource: { - resourceId: 'users', + resourceId: 'adminuser', }, showIn: { edit: false, @@ -275,7 +275,7 @@ export const admin = new AdminForth({ { label: 'Users', icon: 'flowbite:user-solid', - resourceId: 'users', + resourceId: 'adminuser', } ], }); @@ -296,8 +296,8 @@ if (import.meta.url === `file://${process.argv[1]}`) { admin.express.serve(app) admin.discoverDatabases().then(async () => { - if (!await admin.resource('users').get([Filters.EQ('email', 'adminforth')])) { - await admin.resource('users').create({ + if (!await admin.resource('adminuser').get([Filters.EQ('email', 'adminforth')])) { + await admin.resource('adminuser').create({ email: 'adminforth', passwordHash: await AdminForth.Utils.generatePasswordHash('adminforth'), role: 'superadmin', diff --git a/adminforth/documentation/docs/tutorial/03-Customization/03-virtualColumns.md b/adminforth/documentation/docs/tutorial/03-Customization/03-virtualColumns.md index 4f133ec7c..fb3029119 100644 --- a/adminforth/documentation/docs/tutorial/03-Customization/03-virtualColumns.md +++ b/adminforth/documentation/docs/tutorial/03-Customization/03-virtualColumns.md @@ -80,13 +80,13 @@ columns: [ ## Virtual columns for editing. -Another usecase of `virtual` columns is to add new fields in edit and create view. In the [Getting started](/docs/tutorial/001-gettingStarted.md) we used this feature to add `password` field to the `users` resource. +Another usecase of `virtual` columns is to add new fields in edit and create view. In the [Getting started](/docs/tutorial/001-gettingStarted.md) we used this feature to add `password` field to the `adminuser` resource. Thing is that password itself can't be stored in the database, but instead their hash is stored. -So we need to add `password` field to the `users` resource and make it `virtual` so it will not be stored in the database. +So we need to add `password` field to the `adminuser` resource and make it `virtual` so it will not be stored in the database. -```ts title="./resources/users.ts" +```ts title="./resources/adminuser.ts" ... -resourceId: 'users', +resourceId: 'adminuser', ... columns: [ ... diff --git a/adminforth/documentation/docs/tutorial/03-Customization/05-limitingAccess.md b/adminforth/documentation/docs/tutorial/03-Customization/05-limitingAccess.md index 0c3ee0942..a396a358d 100644 --- a/adminforth/documentation/docs/tutorial/03-Customization/05-limitingAccess.md +++ b/adminforth/documentation/docs/tutorial/03-Customization/05-limitingAccess.md @@ -15,10 +15,10 @@ You can use `options.allowedActions` on resource to limit access to the resource If you want to disable deletion of the resource records for all users: -```ts title="./resources/users.ts" +```ts title="./resources/adminuser.ts" { ... - resourceId: 'users', + resourceId: 'adminuser', ... //diff-add options: { @@ -69,7 +69,7 @@ import type { AdminUser } from 'adminforth'; Let's disable creating and editing of new users for all users apart from users with role `superadmin`, and at the same time disable deletion for all users: -```ts title="./resources/users.ts" +```ts title="./resources/adminuser.ts" //diff-add import type { AdminUser } from 'adminforth'; @@ -82,7 +82,7 @@ async function canModifyUsers({ adminUser }: { adminUser: AdminUser }): Promise< { ... - resourceId: 'users', + resourceId: 'adminuser', ... options: { allowedActions: { diff --git a/adminforth/documentation/docs/tutorial/03-Customization/10-menuConfiguration.md b/adminforth/documentation/docs/tutorial/03-Customization/10-menuConfiguration.md index 560035fc1..108ead015 100644 --- a/adminforth/documentation/docs/tutorial/03-Customization/10-menuConfiguration.md +++ b/adminforth/documentation/docs/tutorial/03-Customization/10-menuConfiguration.md @@ -44,7 +44,7 @@ E.g. create group "Blog" with Items who link to resource "posts" and "categories { label: 'Users', icon: 'flowbite:folder-duplicate-outline', - resourceId: 'users', + resourceId: 'adminuser', }, }, ... diff --git a/adminforth/documentation/docs/tutorial/03-Customization/11-dataApi.md b/adminforth/documentation/docs/tutorial/03-Customization/11-dataApi.md index 3e7fe890a..a3bade6e1 100644 --- a/adminforth/documentation/docs/tutorial/03-Customization/11-dataApi.md +++ b/adminforth/documentation/docs/tutorial/03-Customization/11-dataApi.md @@ -14,7 +14,7 @@ This allows you to make basic operations on the data with AdminForth without usi ## Usage -Basically you just import `Filters`, `Sorts` from the `adminforth` package and call the awaitable methods on the `admin.resource('users')`. +Basically you just import `Filters`, `Sorts` from the `adminforth` package and call the awaitable methods on the `admin.resource('adminuser')`. ```ts import { Filters, Sorts } from 'adminforth'; @@ -25,7 +25,7 @@ const admin = new AdminForth({ }); // get the resource object -await admin.resource('users').get([Filters.EQ('id', '1234')]); +await admin.resource('adminuser').get([Filters.EQ('id', '1234')]); ``` Here we will show you how to use the Data API with simple examples. @@ -44,7 +44,7 @@ Signature: Get item by ID: ```ts -const user = await admin.resource('users').get( +const user = await admin.resource('adminuser').get( [Filters.EQ('id', '1234')] ); ``` @@ -61,7 +61,7 @@ const schoolExists = !!(await admin.resource('schools').get( Get user with name 'John' and role not 'SuperAdmin' ```ts -const user = await admin.resource('users').get( +const user = await admin.resource('adminuser').get( [Filters.EQ('name', 'John'), Filters.NEQ('role', 'SuperAdmin')] ); ``` @@ -83,7 +83,7 @@ Signature: Get 15 latest users which role is not Admin: ```ts -const users = await admin.resource('users').list( +const users = await admin.resource('adminuser').list( [Filters.NEQ('role', 'Admin')], 15, 0, Sorts.DESC('createdAt') ); ``` @@ -91,13 +91,13 @@ const users = await admin.resource('users').list( Get 10 oldest users (with highest age): ```ts -const users = await admin.resource('users').list([], 10, 0, Sorts.ASC('age')); +const users = await admin.resource('adminuser').list([], 10, 0, Sorts.ASC('age')); ``` Get next page of oldest users: ```ts -const users = await admin.resource('users').list([], 10, 10, Sorts.ASC('age')); +const users = await admin.resource('adminuser').list([], 10, 10, Sorts.ASC('age')); ``` Get 10 schools, sort by rating first, then oldest by founded year: @@ -162,7 +162,7 @@ const dailyReports = await Promise.all( const dateEnd = new Date(dateStart); dateEnd.setDate(dateEnd.getDate() + 1); - return admin.resource('users').count( + return admin.resource('adminuser').count( [Filters.GTE('createdAt', dateStart.toISOString()), Filters.LT('createdAt', dateEnd.toISOString())] ); }) @@ -217,10 +217,10 @@ Golden rule: create one index per query you are going to use often or where you For example if you have two queries: ```ts -const users = await admin.resource('users').list( +const users = await admin.resource('adminuser').list( [Filters.NEQ('role', 'Admin')], 15, 0, Sorts.DESC('createdAt') ); -const users = await admin.resource('users').list( +const users = await admin.resource('adminuser').list( [Filters.EQ('name', 'John'), Filters.NEQ('role', 'SuperAdmin')] ); ``` diff --git a/adminforth/documentation/docs/tutorial/03-Customization/13-standardPagesTuning.md b/adminforth/documentation/docs/tutorial/03-Customization/13-standardPagesTuning.md index f0ca34755..cae37cf3c 100644 --- a/adminforth/documentation/docs/tutorial/03-Customization/13-standardPagesTuning.md +++ b/adminforth/documentation/docs/tutorial/03-Customization/13-standardPagesTuning.md @@ -346,9 +346,9 @@ export default { In cases when column values must follow certain format, you can add `validation` to it. `validation` is an array of rules, each containing `regExp` that defines a format for a value and `message` that will be displayed in case when entered value does not pass the check. -```typescript title="./resources/users.ts" +```typescript title="./resources/adminuser.ts" export default { - name: 'users', + name: 'adminuser', columns: [ ... { @@ -374,9 +374,9 @@ export default { You can add `editingNote` to a column to show a note below the input field. -```typescript title="./resources/users.ts" +```typescript title="./resources/adminuser.ts" export default { - name: 'users', + name: 'adminuser', columns: [ ... { @@ -393,9 +393,9 @@ export default { Whenever you want to have a column to store not a single value but an array of values you have to set column as `AdminForthDataTypes.JSON`. This way when you are creating or editing a record you can type in a JSON array into a textfield. To simplify this process and allow you to create and edit separate items you can add `isArray` to a column. -```typescript title="./resources/users.ts" +```typescript title="./resources/adminuser.ts" export default { - name: 'users', + name: 'adminuser', columns: [ ... { @@ -422,9 +422,9 @@ Doing so, will result in UI displaying each item of the array as a separate inpu By default it is forbidden to store duplicate values in an array column. To change that you can add `allowDuplicateItems: true` to `isArray`, like so: -```typescript title="./resources/users.ts" +```typescript title="./resources/adminuser.ts" export default { - name: 'users', + name: 'adminuser', columns: [ ... { @@ -452,15 +452,15 @@ Note: array columns can not be marked as `masked`, be a `primaryKey` and at the When you want to create a connection between two resources, you need to add `foreignResource` to a column, like so: -```typescript title="./resources/users.ts" +```typescript title="./resources/adminuser.ts" export default { - name: 'users', + name: 'adminuser', columns: [ ... { name: "realtor_id", foreignResource: { - resourceId: 'users', + resourceId: 'adminuser', }, }, ], diff --git a/adminforth/documentation/docs/tutorial/05-Plugins/01-AuditLog.md b/adminforth/documentation/docs/tutorial/05-Plugins/01-AuditLog.md index 3b035ac8a..e2694174e 100644 --- a/adminforth/documentation/docs/tutorial/05-Plugins/01-AuditLog.md +++ b/adminforth/documentation/docs/tutorial/05-Plugins/01-AuditLog.md @@ -47,7 +47,7 @@ npx --yes prisma migrate dev --name add-audit-logs Also to make this code start ## Setting up the resource and dataSource for plugin -Logger sets up for all the resources by default. But you can exclude unwanted resources with option "excludeResourceIds". In this example, we'll exclude resource "users" from logging. +Logger sets up for all the resources by default. But you can exclude unwanted resources with option "excludeResourceIds". In this example, we'll exclude resource "adminuser" from logging. Also, it excludes itself to avoid infinte logging loop. @@ -69,7 +69,7 @@ Add this code in `auditLogs.ts`: { name: 'resource_id', required: false }, { name: 'user_id', required: false, foreignResource: { - resourceId: 'users', + resourceId: 'adminuser', } }, { name: 'action', required: false }, { name: 'diff', required: false, type: AdminForthDataTypes.JSON, showIn: { @@ -90,7 +90,7 @@ Add this code in `auditLogs.ts`: plugins: [ new AuditLogPlugin({ // if you want to exclude some resources from logging - //excludeResourceIds: ['users'], + //excludeResourceIds: ['adminuser'], resourceColumns: { resourceIdColumnName: 'resource_id', resourceActionColumnName: 'action', diff --git a/adminforth/documentation/docs/tutorial/05-Plugins/02-TwoFactorsAuth.md b/adminforth/documentation/docs/tutorial/05-Plugins/02-TwoFactorsAuth.md index 332637483..21c71010e 100644 --- a/adminforth/documentation/docs/tutorial/05-Plugins/02-TwoFactorsAuth.md +++ b/adminforth/documentation/docs/tutorial/05-Plugins/02-TwoFactorsAuth.md @@ -10,14 +10,14 @@ npm i @adminforth/two-factors-auth --save Plugin is already installed into adminforth, to import: -```ts title="/users.ts" +```ts title="/adminuser.ts" import TwoFactorsAuthPlugin from '@adminforth/two-factors-auth'; ``` Plugin required some additional setup, to make it work properly. It should be added to the resource auth resource. In our example we will add it to the user resource . ```ts title='./schema.prisma' -model users { +model adminuser { id String @id created_at DateTime email String @unique @@ -34,11 +34,11 @@ Then: npx --yes prisma migrate dev --name init ``` -And add it to `users.ts` +And add it to `adminuser.ts` -```ts tittle="./resources/users.ts" +```ts tittle="./resources/adminuser.ts" { - table: 'users', + table: 'adminuser', //diff-add plugins: [ //diff-add @@ -108,7 +108,7 @@ By default plugin enforces Two-Factor Authentication for all users. If you wish to enforce 2FA only for specific users, you can again use `usersFilterToApply` option: -```ts title='./users.ts' +```ts title='./adminuser.ts' usersFilterToApply: (adminUser: AdminUser) => { // disable 2FA for users which email is 'adminforth' or 'adminguest' return !(['adminforth', 'adminguest'].includes(adminUser.dbUser.email)); @@ -117,9 +117,9 @@ If you wish to enforce 2FA only for specific users, you can again use `usersFilt You can even add a boolean column to the user table to store whether the user should use 2FA or not: -```ts title='./users.ts' +```ts title='./adminuser.ts' { - resourceId: 'users', + resourceId: 'adminuser', ... columns: [ ... @@ -162,7 +162,7 @@ By default, all users are required to setup Two-Factor Authentication. If you want to allow specific users to skip the 2FA setup, you can use the `usersFilterToAllowSkipSetup` option: -```ts title='./users.ts' +```ts title='./adminuser.ts' ... plugins: [ new TwoFactorsAuthPlugin ({ diff --git a/adminforth/documentation/docs/tutorial/05-Plugins/03-ForeignInlineList.md b/adminforth/documentation/docs/tutorial/05-Plugins/03-ForeignInlineList.md index 5c3d6187b..781d54533 100644 --- a/adminforth/documentation/docs/tutorial/05-Plugins/03-ForeignInlineList.md +++ b/adminforth/documentation/docs/tutorial/05-Plugins/03-ForeignInlineList.md @@ -10,14 +10,14 @@ Import plugin: npm i @adminforth/foreign-inline-list --save ``` -```ts title="./resources/users.ts" +```ts title="./resources/adminuser.ts" import ForeignInlineListPlugin from '@adminforth/foreign-inline-list'; import { AdminForthResource, AdminForthResourceColumn } from 'adminforth'; ``` In [Getting Started](<../001-gettingStarted.md>) we created a `'aparts'` resource which has a field `'realtor_id'`. -This field refers to record from `'users'` resource. To remind you, we configured this relation using `foreignResource` setting in the column configuration: +This field refers to record from `'adminuser'` resource. To remind you, we configured this relation using `foreignResource` setting in the column configuration: ```typescript title="./resources/apartments.ts" // @@ -29,7 +29,7 @@ export default { { name: 'realtor_id', foreignResource: { - resourceId: 'users', // this means that aparts.realtor_id refers to primary key of 'users' resource + resourceId: 'adminuser', // this means that aparts.realtor_id refers to primary key of 'adminuser' resource // this is Many-To-One relatin: many aparts can refer to one user } } @@ -39,13 +39,13 @@ export default { This means that we can display a list of apartments in the user's show view. -Add to your `'users'` resource configuration the plugin instance: +Add to your `'adminuser'` resource configuration the plugin instance: -```ts title="./resources/users.ts" +```ts title="./resources/adminuser.ts" { ... - resourceId: 'users', + resourceId: 'adminuser', ... //diff-add plugins: [ @@ -77,4 +77,4 @@ You can use `modifyTableResourceConfig` callback to modify what columns to show ![alt text](ForeignInlineList.png) > πŸ‘† To make plugin work, the specified resource (defined with `foreignResourceId`) should have one (and only one) column that refers to the current resource on which you add a plugin. -> In our case we add plugin to `users` resource, so the `aparts` resource should have one column with `foreignResource.resourceId` equal to `users` resourceId. \ No newline at end of file +> In our case we add plugin to `adminuser` resource, so the `aparts` resource should have one column with `foreignResource.resourceId` equal to `adminuser` resourceId. \ No newline at end of file diff --git a/adminforth/documentation/docs/tutorial/05-Plugins/07-email-password-reset.md b/adminforth/documentation/docs/tutorial/05-Plugins/07-email-password-reset.md index bb4c77c47..7080ea29a 100644 --- a/adminforth/documentation/docs/tutorial/05-Plugins/07-email-password-reset.md +++ b/adminforth/documentation/docs/tutorial/05-Plugins/07-email-password-reset.md @@ -34,7 +34,7 @@ To Setup SES, you need to have an AWS account and SES service enabled. You can f Add plugin to user resource: -```typescript ./resources/users.ts +```typescript ./resources/adminuser.ts import EmailResetPasswordPlugin from '@adminforth/email-password-reset'; import EmailAdapterAwsSes from '@adminforth/email-adapter-aws-ses'; ... diff --git a/adminforth/documentation/docs/tutorial/05-Plugins/09-open-signup.md b/adminforth/documentation/docs/tutorial/05-Plugins/09-open-signup.md index fa96c9cec..01ca0db99 100644 --- a/adminforth/documentation/docs/tutorial/05-Plugins/09-open-signup.md +++ b/adminforth/documentation/docs/tutorial/05-Plugins/09-open-signup.md @@ -16,13 +16,13 @@ npm install @adminforth/open-signup --save To use the plugin, instantiate to to user resource: -```typescript title="./resources/user.ts" +```typescript title="./resources/adminuser.ts" import OpenSignupPlugin from '@adminforth/open-signup'; ``` Like this: -```typescript title="./resources/user.ts" +```typescript title="./resources/adminuser.ts" new OpenSignupPlugin({ emailField: 'email', passwordField: 'password', @@ -37,10 +37,10 @@ Please note that in this mode users will be able to sign up without email verifi ## Email verification -First, you need to migrate the `users` table in `./schema.prisma`: +First, you need to migrate the `adminuser` table in `./schema.prisma`: ```ts title='./schema.prisma' -model users { +model adminuser { ... //diff-add email_confirmed Boolean? @default(false) @@ -50,7 +50,7 @@ model users { And prisma migrate: ```bash -npx --yes prisma migrate dev --name add-email-confirmed-to-users +npx --yes prisma migrate dev --name add-email-confirmed-to-adminuser ``` Next, install the `@adminforth/email-adapter-aws-ses` package: @@ -59,17 +59,17 @@ Next, install the `@adminforth/email-adapter-aws-ses` package: npm i @adminforth/email-adapter-aws-ses --save ``` -Also, update the resource configuration in `./resources/users.ts`: +Also, update the resource configuration in `./resources/adminuser.ts`: -```ts title='./resources/users.ts' +```ts title='./resources/adminuser.ts' ... //diff-add import EmailAdapterAwsSes from '@adminforth/email-adapter-aws-ses'; export default { dataSource: 'maindb', - table: 'users', - resourceId: 'users', + table: 'adminuser', + resourceId: 'adminuser', label: 'Users', recordLabel: (r) => `πŸ‘€ ${r.email}`, columns: [