You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 6, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: docs/how-to/add-delete-user-entity.md
+26-13
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ However, you can choose to use your own custom Authentication entity as long as
20
20
21
21
## Dependencies Between the Authentication Entity and Authentication Plugins
22
22
23
-
The authentication plugins, such as the _NestJS Auth Module_ and others, rely on the existence of an _Authentication_ entity to handle user authentication and authorization.
23
+
The authentication pluginsrely on the existence of an _Authentication_ entity to handle user authentication and authorization. For Node.js services, this includes the _NestJS Auth Module_ and others. For .NET services, this includes the _ASP.NET Core Identity_ plugin.
24
24
25
25
If the _Authentication_ entity is not defined or is missing the required fields, the build process will fail, and the authentication plugins will not function correctly.
26
26
@@ -32,15 +32,15 @@ An Authentication plugin requires an Authentication entity containing the proper
32
32
33
33
By default, the 'User' entity is defined as the Authentication entity, but you can [configure it](#changing-the-default-authentication-entity). If the `User` entity is created automatically, it comes with a set of default fields necessary for the authentication plugins to work correctly:
34
34
35
-
-`id` (required by all authentication plugins): An automatically created unique identifier of the entity. It is a required and unique field.
36
-
-`createdAt` (required by all authentication plugins): An automatically created field of the time the entity was created. It is a required field.
37
-
-`updatedAt` (required by all authentication plugins): An automatically created field of the last time the entity was updated. It is a required field.
35
+
-`id` (required): An automatically created unique identifier of the entity. It is a required and unique field.
36
+
-`createdAt` (required): An automatically created field of the time the entity was created. It is a required field.
37
+
-`updatedAt` (required): An automatically created field of the last time the entity was updated. It is a required field.
38
38
-`firstName`: An automatically created field for the first name of the user. It is a searchable single-line text field.
39
39
-`lastName`: An automatically created field for the last name of the user. It is a searchable single-line text field.
40
-
-`username` (required by NestJS Auth Module): An automatically created field for the username of the user. It is a required, unique, and searchable field.
41
-
-`email` (required by NestJS Auth Module): An automatically created field for the email of the user. It is a unique and searchable field.
42
-
-`password` (required by NestJS Auth Module): An automatically created field for the password of the user. It is a required field.
43
-
-`roles` (required by NestJS Auth Module): An automatically created field for the roles of the user. It is a required field.
40
+
-`username` (required): An automatically created field for the username of the user. It is a required, unique, and searchable field.
41
+
-`email` (required): An automatically created field for the email of the user. It is a unique and searchable field.
42
+
-`password` (required): An automatically created field for the password of the user. It is a required field.
43
+
-`roles` (required): An automatically created field for the roles of the user. It is a required field.
44
44
45
45
These default fields provide the necessary information for user authentication and authorization.
46
46
@@ -74,25 +74,34 @@ A popup will appear and give you additional context on restoring the _User_ enti
74
74
Click on the **Restore Default** button and the original _Authentication_ entity provided by Amplication will be restored.
75
75
76
76
:::note
77
-
You have to add the _Authentication_ entity first and then enable the [_NestJS Auth Module_ plugin](/authentication/#nestjs-auth-module-mandatory).
77
+
For Node.js services, you have to add the _Authentication_ entity first and then enable the [_NestJS Auth Module_ plugin](/authentication/#nestjs-auth-module-mandatory).
78
+
For .NET services, the process is similar, but you'll be working with the ASP.NET Core Identity plugin instead.
79
+
78
80
If you try to install the auth plugin first without the _Authentication_ entity, **you will be offered to create it**.
79
81
:::
80
82
81
83
## Deleting The Authentication Entity
82
84
83
85
Usually, it's possible to delete any Entity that you create on your service.
84
86
But, the _Authentication_ entity is special.
85
-
In order to delete it, you must first disable the _NestJS Auth Module_**and any other authentication plugins you installed**.
87
+
In order to delete it, you must first disable the authentication plugin for your service.
88
+
89
+
For Node.js services, this means disabling the _NestJS Auth Module_**and any other authentication plugins you installed**.
90
+
91
+
For .NET services, this involves disabling the ASP.NET Core Identity plugin from your service.
86
92
87
93
:::caution
88
94
It's possible to restore the original _Authentication_ entity provided by Amplication, but any additional fields or permissions you added will be permanently deleted.
89
95
:::
90
96
91
97
Follow these steps to delete the _Authentication_ entity:
92
98
93
-
1. Visit your service's Plugins page and toggle the _NestJS Auth Module_ to the off state. Additional Authentication Plugins also need to be disabled if any were installed.
99
+
1. Visit your service's Plugins page and disable the authentication plugin for your service type.
100
+
101
+
- For Node.js: Toggle the _NestJS Auth Module_ to the off state. Additional Authentication Plugins also need to be disabled if any were installed.
102
+
- For .NET: Disable the ASP.NET Core Identity plugin on your service.
94
103
95
-

104
+

96
105
97
106
2. Visit your service's _Entities_ page.
98
107
You will notice that you can now click the _Authentication_ entity's delete button. Click it and a popup will appear.
@@ -112,4 +121,8 @@ Follow these steps to change the default Authentication entity:
112
121
1. Go to your service's **Settings**.
113
122
2. Go to the **Authentication Entity** page.
114
123
3. Pick the new Entity you want to be the Authentication entity from the **Entity List** dropdown.
115
-
4. You have now set a new Authentication entity.
124
+
4. You have now set a new Authentication entity.
125
+
126
+
:::note
127
+
When changing the default Authentication entity, ensure that the new entity contains all the required fields for your service type (Node.js or .NET) as outlined in the [Authentication Entity Fields](#authentication-entity-fields) section.
0 commit comments