@abpjs/account 0.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +165 -0
- package/README.md +316 -0
- package/dist/components/LoginForm/LoginForm.d.ts +48 -0
- package/dist/components/LoginForm/image-placeholder.d.ts +1 -0
- package/dist/components/LoginForm/index.d.ts +2 -0
- package/dist/components/RegisterForm/RegisterForm.d.ts +50 -0
- package/dist/components/RegisterForm/index.d.ts +2 -0
- package/dist/components/TenantBox/TenantBox.d.ts +21 -0
- package/dist/components/TenantBox/index.d.ts +2 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/usePasswordFlow.d.ts +27 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +574 -0
- package/dist/index.mjs +552 -0
- package/dist/models/index.d.ts +42 -0
- package/dist/pages/LoginPage.d.ts +25 -0
- package/dist/pages/RegisterPage.d.ts +25 -0
- package/dist/pages/index.d.ts +2 -0
- package/dist/providers/AccountProvider.d.ts +40 -0
- package/dist/providers/index.d.ts +1 -0
- package/dist/routes/index.d.ts +24 -0
- package/package.json +70 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
+
of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
|
11
|
+
License, supplemented by the additional permissions listed below.
|
|
12
|
+
|
|
13
|
+
0. Additional Definitions.
|
|
14
|
+
|
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
|
17
|
+
General Public License.
|
|
18
|
+
|
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
|
20
|
+
other than an Application or a Combined Work as defined below.
|
|
21
|
+
|
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
|
25
|
+
of using an interface provided by the Library.
|
|
26
|
+
|
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
|
28
|
+
Application with the Library. The particular version of the Library
|
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
|
30
|
+
Version".
|
|
31
|
+
|
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
35
|
+
based on the Application, and not on the Linked Version.
|
|
36
|
+
|
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
|
38
|
+
object code and/or source code for the Application, including any data
|
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
41
|
+
|
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
|
43
|
+
|
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
|
46
|
+
|
|
47
|
+
2. Conveying Modified Versions.
|
|
48
|
+
|
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
|
51
|
+
that uses the facility (other than as an argument passed when the
|
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
|
53
|
+
version:
|
|
54
|
+
|
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
|
56
|
+
ensure that, in the event an Application does not supply the
|
|
57
|
+
function or data, the facility still operates, and performs
|
|
58
|
+
whatever part of its purpose remains meaningful, or
|
|
59
|
+
|
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
|
61
|
+
this License applicable to that copy.
|
|
62
|
+
|
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
|
64
|
+
|
|
65
|
+
The object code form of an Application may incorporate material from
|
|
66
|
+
a header file that is part of the Library. You may convey such object
|
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
|
68
|
+
material is not limited to numerical parameters, data structure
|
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
|
71
|
+
|
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
|
73
|
+
Library is used in it and that the Library and its use are
|
|
74
|
+
covered by this License.
|
|
75
|
+
|
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
77
|
+
document.
|
|
78
|
+
|
|
79
|
+
4. Combined Works.
|
|
80
|
+
|
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
|
82
|
+
taken together, effectively do not restrict modification of the
|
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
|
85
|
+
the following:
|
|
86
|
+
|
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
|
88
|
+
the Library is used in it and that the Library and its use are
|
|
89
|
+
covered by this License.
|
|
90
|
+
|
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
92
|
+
document.
|
|
93
|
+
|
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
|
95
|
+
execution, include the copyright notice for the Library among
|
|
96
|
+
these notices, as well as a reference directing the user to the
|
|
97
|
+
copies of the GNU GPL and this license document.
|
|
98
|
+
|
|
99
|
+
d) Do one of the following:
|
|
100
|
+
|
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
|
102
|
+
License, and the Corresponding Application Code in a form
|
|
103
|
+
suitable for, and under terms that permit, the user to
|
|
104
|
+
recombine or relink the Application with a modified version of
|
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
|
107
|
+
Corresponding Source.
|
|
108
|
+
|
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
|
111
|
+
a copy of the Library already present on the user's computer
|
|
112
|
+
system, and (b) will operate properly with a modified version of
|
|
113
|
+
the Library that is interface-compatible with the Linked
|
|
114
|
+
Version.
|
|
115
|
+
|
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
|
117
|
+
be required to provide such information under section 6 of the
|
|
118
|
+
GNU GPL, and only to the extent that such information is
|
|
119
|
+
necessary to install and execute a modified version of the
|
|
120
|
+
Combined Work produced by recombining or relinking the
|
|
121
|
+
Application with a modified version of the Linked Version. (If
|
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
|
126
|
+
for conveying Corresponding Source.)
|
|
127
|
+
|
|
128
|
+
5. Combined Libraries.
|
|
129
|
+
|
|
130
|
+
You may place library facilities that are a work based on the
|
|
131
|
+
Library side by side in a single library together with other library
|
|
132
|
+
facilities that are not Applications and are not covered by this
|
|
133
|
+
License, and convey such a combined library under terms of your
|
|
134
|
+
choice, if you do both of the following:
|
|
135
|
+
|
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
|
137
|
+
on the Library, uncombined with any other library facilities,
|
|
138
|
+
conveyed under the terms of this License.
|
|
139
|
+
|
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
|
141
|
+
is a work based on the Library, and explaining where to find the
|
|
142
|
+
accompanying uncombined form of the same work.
|
|
143
|
+
|
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
|
145
|
+
|
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
|
148
|
+
versions will be similar in spirit to the present version, but may
|
|
149
|
+
differ in detail to address new problems or concerns.
|
|
150
|
+
|
|
151
|
+
Each version is given a distinguishing version number. If the
|
|
152
|
+
Library as you received it specifies that a certain numbered version
|
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
|
154
|
+
applies to it, you have the option of following the terms and
|
|
155
|
+
conditions either of that published version or of any later version
|
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
|
160
|
+
|
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
164
|
+
permanent authorization for you to choose that version for the
|
|
165
|
+
Library.
|
package/README.md
ADDED
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
# @abpjs/account
|
|
2
|
+
|
|
3
|
+
> Authentication UI components for ABP Framework in React
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@abpjs/account)
|
|
6
|
+
[](https://www.gnu.org/licenses/lgpl-3.0)
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
`@abpjs/account` provides ready-to-use authentication components for ABP-based React applications. It includes login forms, registration pages, and multi-tenant switching functionality - all styled with Chakra UI and fully customizable.
|
|
11
|
+
|
|
12
|
+
This package is a React translation of the original `@abp/ng.account` Angular package, bringing the same reliable account management to React developers.
|
|
13
|
+
|
|
14
|
+
## Features
|
|
15
|
+
|
|
16
|
+
- **Login Form** - Complete login form with validation and error handling
|
|
17
|
+
- **Registration Form** - User registration with configurable fields
|
|
18
|
+
- **Tenant Switching** - Multi-tenant support with tenant selection UI
|
|
19
|
+
- **Password Flow** - OAuth2 resource owner password flow support
|
|
20
|
+
- **Form Validation** - Built-in validation using Zod schemas
|
|
21
|
+
- **Chakra UI** - Beautiful, accessible components out of the box
|
|
22
|
+
- **Fully Customizable** - Override styles and extend components easily
|
|
23
|
+
- **TypeScript** - Full type safety
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# Using npm
|
|
29
|
+
npm install @abpjs/account
|
|
30
|
+
|
|
31
|
+
# Using yarn
|
|
32
|
+
yarn add @abpjs/account
|
|
33
|
+
|
|
34
|
+
# Using pnpm
|
|
35
|
+
pnpm add @abpjs/account
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Required Dependencies
|
|
39
|
+
|
|
40
|
+
This package requires the following peer dependencies:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npm install @abpjs/core @abpjs/theme-shared @chakra-ui/react @emotion/react @emotion/styled framer-motion react-hook-form zod
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Quick Start
|
|
47
|
+
|
|
48
|
+
### 1. Add Account Routes
|
|
49
|
+
|
|
50
|
+
The simplest way to use this package is to add the pre-configured routes:
|
|
51
|
+
|
|
52
|
+
```tsx
|
|
53
|
+
import { accountRoutes } from '@abpjs/account';
|
|
54
|
+
import { createBrowserRouter, RouterProvider } from 'react-router-dom';
|
|
55
|
+
|
|
56
|
+
const router = createBrowserRouter([
|
|
57
|
+
...accountRoutes,
|
|
58
|
+
// Your other routes
|
|
59
|
+
]);
|
|
60
|
+
|
|
61
|
+
function App() {
|
|
62
|
+
return <RouterProvider router={router} />;
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### 2. Using Individual Components
|
|
67
|
+
|
|
68
|
+
#### Login Form
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
import { LoginForm } from '@abpjs/account';
|
|
72
|
+
|
|
73
|
+
function LoginPage() {
|
|
74
|
+
const handleSuccess = () => {
|
|
75
|
+
// Redirect after successful login
|
|
76
|
+
navigate('/dashboard');
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<div>
|
|
81
|
+
<h1>Welcome Back</h1>
|
|
82
|
+
<LoginForm onSuccess={handleSuccess} />
|
|
83
|
+
</div>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
#### Registration Form
|
|
89
|
+
|
|
90
|
+
```tsx
|
|
91
|
+
import { RegisterForm } from '@abpjs/account';
|
|
92
|
+
|
|
93
|
+
function RegisterPage() {
|
|
94
|
+
const handleSuccess = () => {
|
|
95
|
+
// Redirect after successful registration
|
|
96
|
+
navigate('/login');
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
<div>
|
|
101
|
+
<h1>Create Account</h1>
|
|
102
|
+
<RegisterForm onSuccess={handleSuccess} />
|
|
103
|
+
</div>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
#### Tenant Box
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
import { TenantBox } from '@abpjs/account';
|
|
112
|
+
|
|
113
|
+
function Header() {
|
|
114
|
+
return (
|
|
115
|
+
<header>
|
|
116
|
+
<TenantBox />
|
|
117
|
+
{/* Other header content */}
|
|
118
|
+
</header>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### 3. Using Pre-built Pages
|
|
124
|
+
|
|
125
|
+
```tsx
|
|
126
|
+
import { LoginPage, RegisterPage } from '@abpjs/account';
|
|
127
|
+
import { Routes, Route } from 'react-router-dom';
|
|
128
|
+
|
|
129
|
+
function App() {
|
|
130
|
+
return (
|
|
131
|
+
<Routes>
|
|
132
|
+
<Route path="/login" element={<LoginPage />} />
|
|
133
|
+
<Route path="/register" element={<RegisterPage />} />
|
|
134
|
+
</Routes>
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Components
|
|
140
|
+
|
|
141
|
+
### LoginForm
|
|
142
|
+
|
|
143
|
+
A complete login form with username/email and password fields.
|
|
144
|
+
|
|
145
|
+
```tsx
|
|
146
|
+
import { LoginForm } from '@abpjs/account';
|
|
147
|
+
|
|
148
|
+
<LoginForm
|
|
149
|
+
onSuccess={() => navigate('/dashboard')}
|
|
150
|
+
onError={(error) => console.error(error)}
|
|
151
|
+
showRegisterLink={true}
|
|
152
|
+
showForgotPassword={true}
|
|
153
|
+
/>
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
**Props:**
|
|
157
|
+
|
|
158
|
+
| Prop | Type | Default | Description |
|
|
159
|
+
|------|------|---------|-------------|
|
|
160
|
+
| `onSuccess` | `() => void` | - | Callback after successful login |
|
|
161
|
+
| `onError` | `(error: Error) => void` | - | Callback on login error |
|
|
162
|
+
| `showRegisterLink` | `boolean` | `true` | Show link to registration page |
|
|
163
|
+
| `showForgotPassword` | `boolean` | `true` | Show forgot password link |
|
|
164
|
+
|
|
165
|
+
### RegisterForm
|
|
166
|
+
|
|
167
|
+
User registration form with validation.
|
|
168
|
+
|
|
169
|
+
```tsx
|
|
170
|
+
import { RegisterForm } from '@abpjs/account';
|
|
171
|
+
|
|
172
|
+
<RegisterForm
|
|
173
|
+
onSuccess={() => navigate('/login')}
|
|
174
|
+
onError={(error) => console.error(error)}
|
|
175
|
+
showLoginLink={true}
|
|
176
|
+
/>
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**Props:**
|
|
180
|
+
|
|
181
|
+
| Prop | Type | Default | Description |
|
|
182
|
+
|------|------|---------|-------------|
|
|
183
|
+
| `onSuccess` | `() => void` | - | Callback after successful registration |
|
|
184
|
+
| `onError` | `(error: Error) => void` | - | Callback on registration error |
|
|
185
|
+
| `showLoginLink` | `boolean` | `true` | Show link to login page |
|
|
186
|
+
|
|
187
|
+
### TenantBox
|
|
188
|
+
|
|
189
|
+
Multi-tenant selection component.
|
|
190
|
+
|
|
191
|
+
```tsx
|
|
192
|
+
import { TenantBox } from '@abpjs/account';
|
|
193
|
+
|
|
194
|
+
<TenantBox
|
|
195
|
+
onTenantChange={(tenant) => console.log('Tenant changed:', tenant)}
|
|
196
|
+
/>
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## Hooks
|
|
200
|
+
|
|
201
|
+
### usePasswordFlow
|
|
202
|
+
|
|
203
|
+
Hook for implementing OAuth2 resource owner password flow.
|
|
204
|
+
|
|
205
|
+
```tsx
|
|
206
|
+
import { usePasswordFlow } from '@abpjs/account';
|
|
207
|
+
|
|
208
|
+
function CustomLoginForm() {
|
|
209
|
+
const { login, isLoading, error } = usePasswordFlow();
|
|
210
|
+
|
|
211
|
+
const handleSubmit = async (data) => {
|
|
212
|
+
await login({
|
|
213
|
+
username: data.username,
|
|
214
|
+
password: data.password,
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
return (
|
|
219
|
+
<form onSubmit={handleSubmit}>
|
|
220
|
+
{/* Your custom form */}
|
|
221
|
+
</form>
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## Customization
|
|
227
|
+
|
|
228
|
+
### Styling with Chakra UI
|
|
229
|
+
|
|
230
|
+
All components use Chakra UI and can be styled using Chakra's theming system:
|
|
231
|
+
|
|
232
|
+
```tsx
|
|
233
|
+
import { extendTheme, ChakraProvider } from '@chakra-ui/react';
|
|
234
|
+
|
|
235
|
+
const theme = extendTheme({
|
|
236
|
+
components: {
|
|
237
|
+
Button: {
|
|
238
|
+
defaultProps: {
|
|
239
|
+
colorScheme: 'blue',
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
},
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
function App() {
|
|
246
|
+
return (
|
|
247
|
+
<ChakraProvider theme={theme}>
|
|
248
|
+
<LoginForm />
|
|
249
|
+
</ChakraProvider>
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### Custom Validation
|
|
255
|
+
|
|
256
|
+
Override validation schemas using Zod:
|
|
257
|
+
|
|
258
|
+
```tsx
|
|
259
|
+
import { z } from 'zod';
|
|
260
|
+
|
|
261
|
+
const customLoginSchema = z.object({
|
|
262
|
+
username: z.string().email('Must be a valid email'),
|
|
263
|
+
password: z.string().min(8, 'Password must be at least 8 characters'),
|
|
264
|
+
});
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
## Multi-Tenancy
|
|
268
|
+
|
|
269
|
+
The account module fully supports ABP's multi-tenant architecture:
|
|
270
|
+
|
|
271
|
+
1. **Tenant Selection** - Users can select their tenant before login
|
|
272
|
+
2. **Tenant Header** - Automatically includes tenant header in API requests
|
|
273
|
+
3. **Tenant Persistence** - Remembers selected tenant across sessions
|
|
274
|
+
|
|
275
|
+
```tsx
|
|
276
|
+
import { TenantBox } from '@abpjs/account';
|
|
277
|
+
|
|
278
|
+
// Show tenant selector in your app header
|
|
279
|
+
function AppHeader() {
|
|
280
|
+
return (
|
|
281
|
+
<header>
|
|
282
|
+
<Logo />
|
|
283
|
+
<TenantBox />
|
|
284
|
+
<UserMenu />
|
|
285
|
+
</header>
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
## Integration with ABP Backend
|
|
291
|
+
|
|
292
|
+
This package is designed to work seamlessly with ABP Framework backends:
|
|
293
|
+
|
|
294
|
+
- Compatible with ABP's Identity Server integration
|
|
295
|
+
- Supports ABP's account module API endpoints
|
|
296
|
+
- Works with ABP's multi-tenant system
|
|
297
|
+
|
|
298
|
+
## Related Packages
|
|
299
|
+
|
|
300
|
+
- [@abpjs/core](https://www.npmjs.com/package/@abpjs/core) - Core infrastructure (required)
|
|
301
|
+
- [@abpjs/theme-shared](https://www.npmjs.com/package/@abpjs/theme-shared) - Shared UI components (required)
|
|
302
|
+
- [@abpjs/theme-basic](https://www.npmjs.com/package/@abpjs/theme-basic) - Layout components
|
|
303
|
+
- [@abpjs/permission-management](https://www.npmjs.com/package/@abpjs/permission-management) - Permission management
|
|
304
|
+
- [@abpjs/tenant-management](https://www.npmjs.com/package/@abpjs/tenant-management) - Tenant administration
|
|
305
|
+
|
|
306
|
+
## Contributing
|
|
307
|
+
|
|
308
|
+
This package is part of the [ABP React](https://github.com/abpjs/abp-react) monorepo. Contributions are welcome!
|
|
309
|
+
|
|
310
|
+
## License
|
|
311
|
+
|
|
312
|
+
LGPL-3.0 - See [LICENSE](https://github.com/abpjs/abp-react/blob/main/LICENSE) for details.
|
|
313
|
+
|
|
314
|
+
---
|
|
315
|
+
|
|
316
|
+
**[View Full Documentation](https://docs.abpjs.io/docs/packages/account/overview)** | **[Report Issues](https://github.com/abpjs/abp-react/issues)** | **[View Source](https://github.com/abpjs/abp-react/tree/main/packages/account)**
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Props for LoginForm component
|
|
3
|
+
*/
|
|
4
|
+
export interface LoginFormProps {
|
|
5
|
+
/**
|
|
6
|
+
* Whether to show the tenant box
|
|
7
|
+
* @default true
|
|
8
|
+
*/
|
|
9
|
+
showTenantBox?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Whether to show the register link
|
|
12
|
+
* @default true
|
|
13
|
+
*/
|
|
14
|
+
showRegisterLink?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Custom register URL
|
|
17
|
+
* @default '/account/register'
|
|
18
|
+
*/
|
|
19
|
+
registerUrl?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Callback fired on successful login
|
|
22
|
+
*/
|
|
23
|
+
onLoginSuccess?: () => void;
|
|
24
|
+
/**
|
|
25
|
+
* Callback fired on login error
|
|
26
|
+
*/
|
|
27
|
+
onLoginError?: (error: string) => void;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* LoginForm - User login form component
|
|
31
|
+
*
|
|
32
|
+
* This is the React equivalent of Angular's LoginComponent.
|
|
33
|
+
* It handles user authentication using OAuth password flow.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```tsx
|
|
37
|
+
* function LoginPage() {
|
|
38
|
+
* return (
|
|
39
|
+
* <LoginForm
|
|
40
|
+
* showTenantBox={true}
|
|
41
|
+
* onLoginSuccess={() => console.log('Logged in!')}
|
|
42
|
+
* />
|
|
43
|
+
* );
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare function LoginForm({ showTenantBox, showRegisterLink, registerUrl, onLoginSuccess, onLoginError, }: LoginFormProps): import("react/jsx-runtime").JSX.Element;
|
|
48
|
+
export default LoginForm;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ImagePlaceholder: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Props for RegisterForm component
|
|
3
|
+
*/
|
|
4
|
+
export interface RegisterFormProps {
|
|
5
|
+
/**
|
|
6
|
+
* Whether to show the tenant box
|
|
7
|
+
* @default true
|
|
8
|
+
*/
|
|
9
|
+
showTenantBox?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Whether to show the login link
|
|
12
|
+
* @default true
|
|
13
|
+
*/
|
|
14
|
+
showLoginLink?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Custom login URL
|
|
17
|
+
* @default '/account/login'
|
|
18
|
+
*/
|
|
19
|
+
loginUrl?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Callback fired on successful registration
|
|
22
|
+
*/
|
|
23
|
+
onRegisterSuccess?: () => void;
|
|
24
|
+
/**
|
|
25
|
+
* Callback fired on registration error
|
|
26
|
+
*/
|
|
27
|
+
onRegisterError?: (error: string) => void;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* RegisterForm - User registration form component
|
|
31
|
+
*
|
|
32
|
+
* This is the React equivalent of Angular's RegisterComponent.
|
|
33
|
+
*
|
|
34
|
+
* Note: In v0.7.6, the onSubmit only validates the form but does not
|
|
35
|
+
* make an API call. This matches the Angular implementation.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```tsx
|
|
39
|
+
* function RegisterPage() {
|
|
40
|
+
* return (
|
|
41
|
+
* <RegisterForm
|
|
42
|
+
* showTenantBox={true}
|
|
43
|
+
* onRegisterSuccess={() => console.log('Registered!')}
|
|
44
|
+
* />
|
|
45
|
+
* );
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare function RegisterForm({ showTenantBox, showLoginLink, loginUrl, onRegisterSuccess, onRegisterError: _onRegisterError, }: RegisterFormProps): import("react/jsx-runtime").JSX.Element;
|
|
50
|
+
export default RegisterForm;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Props for TenantBox component
|
|
4
|
+
*/
|
|
5
|
+
export interface TenantBoxProps {
|
|
6
|
+
/**
|
|
7
|
+
* Custom styles for the container
|
|
8
|
+
*/
|
|
9
|
+
containerStyle?: React.CSSProperties;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* TenantBox - Multi-tenant switching component
|
|
13
|
+
*
|
|
14
|
+
* Displays the currently selected tenant and allows users to switch tenants.
|
|
15
|
+
* This is a direct translation of Angular's TenantBoxComponent.
|
|
16
|
+
*
|
|
17
|
+
* Note: In v0.7.6, this component stores the tenant selection locally
|
|
18
|
+
* and does not integrate with the backend tenant resolution API.
|
|
19
|
+
*/
|
|
20
|
+
export declare function TenantBox({ containerStyle }: TenantBoxProps): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export default TenantBox;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { PasswordFlowResult } from '../models';
|
|
2
|
+
/**
|
|
3
|
+
* Options for password flow login
|
|
4
|
+
*/
|
|
5
|
+
export interface PasswordFlowOptions {
|
|
6
|
+
/**
|
|
7
|
+
* If true, store tokens in localStorage (persistent)
|
|
8
|
+
* If false, store in sessionStorage (session only)
|
|
9
|
+
* @default false
|
|
10
|
+
*/
|
|
11
|
+
remember?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Hook for OAuth Resource Owner Password Credentials (ROPC) flow
|
|
15
|
+
*
|
|
16
|
+
* This hook provides password-based authentication, which is used by the
|
|
17
|
+
* login form to authenticate users with username and password.
|
|
18
|
+
*
|
|
19
|
+
* Note: ROPC flow is considered legacy by OAuth 2.1 but is still used
|
|
20
|
+
* in many enterprise scenarios where the client is trusted.
|
|
21
|
+
*/
|
|
22
|
+
export declare function usePasswordFlow(): {
|
|
23
|
+
login: (username: string, password: string, flowOptions?: PasswordFlowOptions) => Promise<PasswordFlowResult>;
|
|
24
|
+
isLoading: boolean;
|
|
25
|
+
error: string | null;
|
|
26
|
+
clearError: () => void;
|
|
27
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @abpjs/account
|
|
3
|
+
* ABP Framework Account module for React
|
|
4
|
+
* Translated from @abp/ng.account v0.7.6
|
|
5
|
+
*/
|
|
6
|
+
export * from './models';
|
|
7
|
+
export * from './providers';
|
|
8
|
+
export * from './hooks';
|
|
9
|
+
export * from './components';
|
|
10
|
+
export * from './pages';
|
|
11
|
+
export * from './routes';
|