@nocobase/plugin-auth 0.13.0-alpha.4 → 0.13.0-alpha.5
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/dist/client/index.js +2 -744
- package/dist/index.js +36 -18
- package/dist/locale/zh-CN.js +22 -4
- package/dist/node_modules/cron/lib/cron.js +1 -1
- package/dist/node_modules/cron/package.json +1 -1
- package/dist/preset.js +32 -9
- package/dist/server/actions/auth.js +22 -4
- package/dist/server/actions/authenticators.js +25 -8
- package/dist/server/basic-auth.js +49 -22
- package/dist/server/collections/authenticators.js +22 -4
- package/dist/server/collections/token-blacklist.js +22 -4
- package/dist/server/collections/users-authenticators.js +22 -4
- package/dist/server/index.js +37 -19
- package/dist/server/locale/en-US.js +22 -4
- package/dist/server/locale/fr-FR.js +22 -4
- package/dist/server/locale/index.js +41 -24
- package/dist/server/locale/ja-JP.js +22 -4
- package/dist/server/locale/pt-BR.js +22 -4
- package/dist/server/locale/zh-CN.js +22 -4
- package/dist/server/migrations/20230506152253-basic-authenticator.js +27 -10
- package/dist/server/migrations/20230607174500-update-basic.js +26 -9
- package/dist/server/model/authenticator.js +28 -7
- package/dist/server/plugin.js +60 -36
- package/dist/server/token-blacklist.js +26 -4
- package/dist/swagger/index.js +22 -4
- package/package.json +2 -2
package/dist/client/index.js
CHANGED
|
@@ -1,541 +1,4 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("@nocobase/client"), require("react"), require("antd"), require("@formily/shared"), require("react-i18next"), require("@ant-design/icons"), require("@formily/react")) : typeof define === "function" && define.amd ? define(["exports", "@nocobase/client", "react", "antd", "@formily/shared", "react-i18next", "@ant-design/icons", "@formily/react"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["@nocobase/plugin-auth"] = {}, global["@nocobase/client"], global.react, global.antd, global["@formily/shared"], global["react-i18next"], global["@ant-design/icons"], global["@formily/react"]));
|
|
3
|
-
})(this, function(exports2, client, require$$0, antd, shared, reactI18next, icons, react) {
|
|
4
|
-
"use strict";
|
|
5
|
-
var jsxRuntime = { exports: {} };
|
|
6
|
-
var reactJsxRuntime_production_min = {};
|
|
7
|
-
/**
|
|
8
|
-
* @license React
|
|
9
|
-
* react-jsx-runtime.production.min.js
|
|
10
|
-
*
|
|
11
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
12
|
-
*
|
|
13
|
-
* This source code is licensed under the MIT license found in the
|
|
14
|
-
* LICENSE file in the root directory of this source tree.
|
|
15
|
-
*/
|
|
16
|
-
var f = require$$0, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: true, ref: true, __self: true, __source: true };
|
|
17
|
-
function q(c, a, g) {
|
|
18
|
-
var b, d = {}, e = null, h = null;
|
|
19
|
-
void 0 !== g && (e = "" + g);
|
|
20
|
-
void 0 !== a.key && (e = "" + a.key);
|
|
21
|
-
void 0 !== a.ref && (h = a.ref);
|
|
22
|
-
for (b in a)
|
|
23
|
-
m.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
|
|
24
|
-
if (c && c.defaultProps)
|
|
25
|
-
for (b in a = c.defaultProps, a)
|
|
26
|
-
void 0 === d[b] && (d[b] = a[b]);
|
|
27
|
-
return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current };
|
|
28
|
-
}
|
|
29
|
-
reactJsxRuntime_production_min.Fragment = l;
|
|
30
|
-
reactJsxRuntime_production_min.jsx = q;
|
|
31
|
-
reactJsxRuntime_production_min.jsxs = q;
|
|
32
|
-
{
|
|
33
|
-
jsxRuntime.exports = reactJsxRuntime_production_min;
|
|
34
|
-
}
|
|
35
|
-
var jsxRuntimeExports = jsxRuntime.exports;
|
|
36
|
-
const AuthTypeContext = require$$0.createContext({ type: "" });
|
|
37
|
-
const AuthTypesContext = require$$0.createContext({ types: [] });
|
|
38
|
-
const useAuthTypes = () => {
|
|
39
|
-
const { types } = require$$0.useContext(AuthTypesContext);
|
|
40
|
-
return types;
|
|
41
|
-
};
|
|
42
|
-
const collection = {
|
|
43
|
-
name: "authenticators",
|
|
44
|
-
sortable: true,
|
|
45
|
-
fields: [
|
|
46
|
-
{
|
|
47
|
-
name: "id",
|
|
48
|
-
type: "string",
|
|
49
|
-
interface: "id"
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
interface: "input",
|
|
53
|
-
type: "string",
|
|
54
|
-
name: "name",
|
|
55
|
-
uiSchema: {
|
|
56
|
-
type: "string",
|
|
57
|
-
title: '{{t("Auth UID")}}',
|
|
58
|
-
"x-component": "Input",
|
|
59
|
-
required: true
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
interface: "input",
|
|
64
|
-
type: "string",
|
|
65
|
-
name: "authType",
|
|
66
|
-
uiSchema: {
|
|
67
|
-
type: "string",
|
|
68
|
-
title: '{{t("Auth Type")}}',
|
|
69
|
-
"x-component": "Select",
|
|
70
|
-
dataSource: "{{ types }}",
|
|
71
|
-
required: true
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
interface: "input",
|
|
76
|
-
type: "string",
|
|
77
|
-
name: "title",
|
|
78
|
-
uiSchema: {
|
|
79
|
-
type: "string",
|
|
80
|
-
title: '{{t("Title")}}',
|
|
81
|
-
"x-component": "Input"
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
interface: "textarea",
|
|
86
|
-
type: "string",
|
|
87
|
-
name: "description",
|
|
88
|
-
uiSchema: {
|
|
89
|
-
type: "string",
|
|
90
|
-
title: '{{t("Description")}}',
|
|
91
|
-
"x-component": "Input"
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
type: "boolean",
|
|
96
|
-
name: "enabled",
|
|
97
|
-
uiSchema: {
|
|
98
|
-
type: "boolean",
|
|
99
|
-
title: '{{t("Enabled")}}',
|
|
100
|
-
"x-component": "Checkbox"
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
]
|
|
104
|
-
};
|
|
105
|
-
const createFormSchema = {
|
|
106
|
-
type: "object",
|
|
107
|
-
properties: {
|
|
108
|
-
drawer: {
|
|
109
|
-
type: "void",
|
|
110
|
-
"x-component": "Action.Drawer",
|
|
111
|
-
"x-decorator": "Form",
|
|
112
|
-
"x-decorator-props": {
|
|
113
|
-
useValues(options) {
|
|
114
|
-
const ctx = client.useActionContext();
|
|
115
|
-
const { type: authType } = require$$0.useContext(AuthTypeContext);
|
|
116
|
-
return client.useRequest(
|
|
117
|
-
() => Promise.resolve({
|
|
118
|
-
data: {
|
|
119
|
-
name: `s_${shared.uid()}`,
|
|
120
|
-
authType
|
|
121
|
-
}
|
|
122
|
-
}),
|
|
123
|
-
{ ...options, refreshDeps: [ctx.visible] }
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
title: '{{t("Add new")}}',
|
|
128
|
-
properties: {
|
|
129
|
-
name: {
|
|
130
|
-
"x-component": "CollectionField",
|
|
131
|
-
"x-decorator": "FormItem"
|
|
132
|
-
},
|
|
133
|
-
authType: {
|
|
134
|
-
"x-component": "CollectionField",
|
|
135
|
-
"x-decorator": "FormItem",
|
|
136
|
-
"x-component-props": {
|
|
137
|
-
options: "{{ types }}"
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
|
-
title: {
|
|
141
|
-
"x-component": "CollectionField",
|
|
142
|
-
"x-decorator": "FormItem"
|
|
143
|
-
},
|
|
144
|
-
description: {
|
|
145
|
-
"x-component": "CollectionField",
|
|
146
|
-
"x-decorator": "FormItem"
|
|
147
|
-
},
|
|
148
|
-
enabled: {
|
|
149
|
-
"x-component": "CollectionField",
|
|
150
|
-
"x-decorator": "FormItem"
|
|
151
|
-
},
|
|
152
|
-
options: {
|
|
153
|
-
type: "object",
|
|
154
|
-
"x-component": "Options"
|
|
155
|
-
},
|
|
156
|
-
footer: {
|
|
157
|
-
type: "void",
|
|
158
|
-
"x-component": "Action.Drawer.Footer",
|
|
159
|
-
properties: {
|
|
160
|
-
cancel: {
|
|
161
|
-
title: '{{t("Cancel")}}',
|
|
162
|
-
"x-component": "Action",
|
|
163
|
-
"x-component-props": {
|
|
164
|
-
useAction: "{{ cm.useCancelAction }}"
|
|
165
|
-
}
|
|
166
|
-
},
|
|
167
|
-
submit: {
|
|
168
|
-
title: '{{t("Submit")}}',
|
|
169
|
-
"x-component": "Action",
|
|
170
|
-
"x-component-props": {
|
|
171
|
-
type: "primary",
|
|
172
|
-
useAction: "{{ cm.useCreateAction }}"
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
const authenticatorsSchema = {
|
|
182
|
-
type: "void",
|
|
183
|
-
name: "authenticators",
|
|
184
|
-
"x-decorator": "ResourceActionProvider",
|
|
185
|
-
"x-decorator-props": {
|
|
186
|
-
collection,
|
|
187
|
-
resourceName: "authenticators",
|
|
188
|
-
dragSort: true,
|
|
189
|
-
request: {
|
|
190
|
-
resource: "authenticators",
|
|
191
|
-
action: "list",
|
|
192
|
-
params: {
|
|
193
|
-
pageSize: 50,
|
|
194
|
-
sort: "sort",
|
|
195
|
-
appends: []
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
},
|
|
199
|
-
"x-component": "CollectionProvider",
|
|
200
|
-
"x-component-props": {
|
|
201
|
-
collection
|
|
202
|
-
},
|
|
203
|
-
properties: {
|
|
204
|
-
actions: {
|
|
205
|
-
type: "void",
|
|
206
|
-
"x-component": "ActionBar",
|
|
207
|
-
"x-component-props": {
|
|
208
|
-
style: {
|
|
209
|
-
marginBottom: 16
|
|
210
|
-
}
|
|
211
|
-
},
|
|
212
|
-
properties: {
|
|
213
|
-
delete: {
|
|
214
|
-
type: "void",
|
|
215
|
-
title: '{{t("Delete")}}',
|
|
216
|
-
"x-component": "Action",
|
|
217
|
-
"x-component-props": {
|
|
218
|
-
useAction: "{{ cm.useBulkDestroyAction }}",
|
|
219
|
-
confirm: {
|
|
220
|
-
title: "{{t('Delete')}}",
|
|
221
|
-
content: "{{t('Are you sure you want to delete it?')}}"
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
},
|
|
225
|
-
create: {
|
|
226
|
-
type: "void",
|
|
227
|
-
title: '{{t("Add new")}}',
|
|
228
|
-
"x-component": "AddNew",
|
|
229
|
-
"x-component-props": {
|
|
230
|
-
type: "primary"
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
},
|
|
235
|
-
table: {
|
|
236
|
-
type: "void",
|
|
237
|
-
"x-uid": "input",
|
|
238
|
-
"x-component": "Table.Void",
|
|
239
|
-
"x-component-props": {
|
|
240
|
-
rowKey: "id",
|
|
241
|
-
rowSelection: {
|
|
242
|
-
type: "checkbox"
|
|
243
|
-
},
|
|
244
|
-
useDataSource: "{{ cm.useDataSourceFromRAC }}",
|
|
245
|
-
useAction() {
|
|
246
|
-
const api = client.useAPIClient();
|
|
247
|
-
const { t } = reactI18next.useTranslation();
|
|
248
|
-
return {
|
|
249
|
-
async move(from, to) {
|
|
250
|
-
await api.resource("authenticators").move({
|
|
251
|
-
sourceId: from.id,
|
|
252
|
-
targetId: to.id
|
|
253
|
-
});
|
|
254
|
-
antd.message.success(t("Saved successfully"), 0.2);
|
|
255
|
-
}
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
},
|
|
259
|
-
properties: {
|
|
260
|
-
id: {
|
|
261
|
-
type: "void",
|
|
262
|
-
"x-decorator": "Table.Column.Decorator",
|
|
263
|
-
"x-component": "Table.Column",
|
|
264
|
-
properties: {
|
|
265
|
-
id: {
|
|
266
|
-
type: "number",
|
|
267
|
-
"x-component": "CollectionField",
|
|
268
|
-
"x-read-pretty": true
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
},
|
|
272
|
-
name: {
|
|
273
|
-
type: "void",
|
|
274
|
-
"x-decorator": "Table.Column.Decorator",
|
|
275
|
-
"x-component": "Table.Column",
|
|
276
|
-
properties: {
|
|
277
|
-
name: {
|
|
278
|
-
type: "string",
|
|
279
|
-
"x-component": "CollectionField",
|
|
280
|
-
"x-read-pretty": true
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
},
|
|
284
|
-
authType: {
|
|
285
|
-
title: '{{t("Auth Type")}}',
|
|
286
|
-
type: "void",
|
|
287
|
-
"x-decorator": "Table.Column.Decorator",
|
|
288
|
-
"x-component": "Table.Column",
|
|
289
|
-
properties: {
|
|
290
|
-
authType: {
|
|
291
|
-
type: "string",
|
|
292
|
-
"x-component": "Select",
|
|
293
|
-
"x-read-pretty": true,
|
|
294
|
-
enum: "{{ types }}"
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
},
|
|
298
|
-
title: {
|
|
299
|
-
type: "void",
|
|
300
|
-
"x-decorator": "Table.Column.Decorator",
|
|
301
|
-
"x-component": "Table.Column",
|
|
302
|
-
properties: {
|
|
303
|
-
title: {
|
|
304
|
-
type: "string",
|
|
305
|
-
"x-component": "CollectionField",
|
|
306
|
-
"x-read-pretty": true
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
},
|
|
310
|
-
description: {
|
|
311
|
-
type: "void",
|
|
312
|
-
"x-decorator": "Table.Column.Decorator",
|
|
313
|
-
"x-component": "Table.Column",
|
|
314
|
-
properties: {
|
|
315
|
-
description: {
|
|
316
|
-
type: "boolean",
|
|
317
|
-
"x-component": "CollectionField",
|
|
318
|
-
"x-read-pretty": true
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
},
|
|
322
|
-
enabled: {
|
|
323
|
-
type: "void",
|
|
324
|
-
"x-decorator": "Table.Column.Decorator",
|
|
325
|
-
"x-component": "Table.Column",
|
|
326
|
-
properties: {
|
|
327
|
-
enabled: {
|
|
328
|
-
type: "boolean",
|
|
329
|
-
"x-component": "CollectionField",
|
|
330
|
-
"x-read-pretty": true
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
},
|
|
334
|
-
actions: {
|
|
335
|
-
type: "void",
|
|
336
|
-
title: '{{t("Actions")}}',
|
|
337
|
-
"x-component": "Table.Column",
|
|
338
|
-
properties: {
|
|
339
|
-
actions: {
|
|
340
|
-
type: "void",
|
|
341
|
-
"x-component": "Space",
|
|
342
|
-
"x-component-props": {
|
|
343
|
-
split: "|"
|
|
344
|
-
},
|
|
345
|
-
properties: {
|
|
346
|
-
update: {
|
|
347
|
-
type: "void",
|
|
348
|
-
title: '{{t("Configure")}}',
|
|
349
|
-
"x-component": "Action.Link",
|
|
350
|
-
"x-component-props": {
|
|
351
|
-
type: "primary"
|
|
352
|
-
},
|
|
353
|
-
properties: {
|
|
354
|
-
drawer: {
|
|
355
|
-
type: "void",
|
|
356
|
-
"x-component": "Action.Drawer",
|
|
357
|
-
"x-decorator": "Form",
|
|
358
|
-
"x-decorator-props": {
|
|
359
|
-
useValues: "{{ cm.useValuesFromRecord }}"
|
|
360
|
-
},
|
|
361
|
-
title: '{{t("Configure")}}',
|
|
362
|
-
properties: {
|
|
363
|
-
name: {
|
|
364
|
-
"x-component": "CollectionField",
|
|
365
|
-
"x-decorator": "FormItem"
|
|
366
|
-
},
|
|
367
|
-
authType: {
|
|
368
|
-
"x-component": "CollectionField",
|
|
369
|
-
"x-decorator": "FormItem",
|
|
370
|
-
"x-component-props": {
|
|
371
|
-
options: "{{ types }}"
|
|
372
|
-
}
|
|
373
|
-
},
|
|
374
|
-
title: {
|
|
375
|
-
"x-component": "CollectionField",
|
|
376
|
-
"x-decorator": "FormItem"
|
|
377
|
-
},
|
|
378
|
-
description: {
|
|
379
|
-
"x-component": "CollectionField",
|
|
380
|
-
"x-decorator": "FormItem"
|
|
381
|
-
},
|
|
382
|
-
enabled: {
|
|
383
|
-
"x-component": "CollectionField",
|
|
384
|
-
"x-decorator": "FormItem"
|
|
385
|
-
},
|
|
386
|
-
options: {
|
|
387
|
-
type: "object",
|
|
388
|
-
"x-component": "Options"
|
|
389
|
-
},
|
|
390
|
-
footer: {
|
|
391
|
-
type: "void",
|
|
392
|
-
"x-component": "Action.Drawer.Footer",
|
|
393
|
-
properties: {
|
|
394
|
-
cancel: {
|
|
395
|
-
title: '{{t("Cancel")}}',
|
|
396
|
-
"x-component": "Action",
|
|
397
|
-
"x-component-props": {
|
|
398
|
-
useAction: "{{ cm.useCancelAction }}"
|
|
399
|
-
}
|
|
400
|
-
},
|
|
401
|
-
submit: {
|
|
402
|
-
title: '{{t("Submit")}}',
|
|
403
|
-
"x-component": "Action",
|
|
404
|
-
"x-component-props": {
|
|
405
|
-
type: "primary",
|
|
406
|
-
useAction: "{{ cm.useUpdateAction }}"
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
},
|
|
415
|
-
delete: {
|
|
416
|
-
type: "void",
|
|
417
|
-
title: '{{ t("Delete") }}',
|
|
418
|
-
"x-component": "Action.Link",
|
|
419
|
-
"x-component-props": {
|
|
420
|
-
confirm: {
|
|
421
|
-
title: "{{t('Delete record')}}",
|
|
422
|
-
content: "{{t('Are you sure you want to delete it?')}}"
|
|
423
|
-
},
|
|
424
|
-
useAction: "{{cm.useDestroyAction}}"
|
|
425
|
-
},
|
|
426
|
-
"x-disabled": "{{ useCanNotDelete() }}"
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
};
|
|
436
|
-
const useValuesFromOptions = (options) => {
|
|
437
|
-
const record = client.useRecord();
|
|
438
|
-
const result = client.useRequest(
|
|
439
|
-
() => Promise.resolve({
|
|
440
|
-
data: {
|
|
441
|
-
...record.options
|
|
442
|
-
}
|
|
443
|
-
}),
|
|
444
|
-
{
|
|
445
|
-
...options,
|
|
446
|
-
manual: true
|
|
447
|
-
}
|
|
448
|
-
);
|
|
449
|
-
const { run } = result;
|
|
450
|
-
const ctx = client.useActionContext();
|
|
451
|
-
require$$0.useEffect(() => {
|
|
452
|
-
if (ctx.visible) {
|
|
453
|
-
run();
|
|
454
|
-
}
|
|
455
|
-
}, [ctx.visible, run]);
|
|
456
|
-
return result;
|
|
457
|
-
};
|
|
458
|
-
const Options$1 = react.observer(() => {
|
|
459
|
-
const form = react.useForm();
|
|
460
|
-
const record = client.useRecord();
|
|
461
|
-
const component = client.useOptionsComponent(form.values.authType || record.authType);
|
|
462
|
-
return component;
|
|
463
|
-
});
|
|
464
|
-
const NAMESPACE = "auth";
|
|
465
|
-
function useAuthTranslation() {
|
|
466
|
-
return reactI18next.useTranslation(NAMESPACE);
|
|
467
|
-
}
|
|
468
|
-
const useCloseAction = () => {
|
|
469
|
-
const { setVisible } = client.useActionContext();
|
|
470
|
-
return {
|
|
471
|
-
async run() {
|
|
472
|
-
setVisible(false);
|
|
473
|
-
}
|
|
474
|
-
};
|
|
475
|
-
};
|
|
476
|
-
const AddNew = () => {
|
|
477
|
-
const { t } = reactI18next.useTranslation();
|
|
478
|
-
const [visible, setVisible] = require$$0.useState(false);
|
|
479
|
-
const [type, setType] = require$$0.useState("");
|
|
480
|
-
const types = useAuthTypes();
|
|
481
|
-
const items = types.map((item) => ({
|
|
482
|
-
...item,
|
|
483
|
-
onClick: () => {
|
|
484
|
-
setVisible(true);
|
|
485
|
-
setType(item.value);
|
|
486
|
-
}
|
|
487
|
-
}));
|
|
488
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(client.ActionContextProvider, { value: { visible, setVisible }, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(AuthTypeContext.Provider, { value: { type }, children: [
|
|
489
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(antd.Dropdown, { menu: { items }, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(antd.Button, { icon: /* @__PURE__ */ jsxRuntimeExports.jsx(icons.PlusOutlined, {}), type: "primary", children: [
|
|
490
|
-
t("Add new"),
|
|
491
|
-
" ",
|
|
492
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(icons.DownOutlined, {})
|
|
493
|
-
] }) }),
|
|
494
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(client.SchemaComponent, { scope: { useCloseAction, types, setType }, schema: createFormSchema })
|
|
495
|
-
] }) });
|
|
496
|
-
};
|
|
497
|
-
const useCanNotDelete = () => {
|
|
498
|
-
client.useAsyncData();
|
|
499
|
-
return false;
|
|
500
|
-
};
|
|
501
|
-
const Authenticator = () => {
|
|
502
|
-
const { t } = useAuthTranslation();
|
|
503
|
-
const [types, setTypes] = require$$0.useState([]);
|
|
504
|
-
const api = client.useAPIClient();
|
|
505
|
-
client.useRequest(
|
|
506
|
-
() => api.resource("authenticators").listTypes().then((res) => {
|
|
507
|
-
var _a;
|
|
508
|
-
const types2 = ((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.data) || [];
|
|
509
|
-
return types2.map((type) => ({
|
|
510
|
-
key: type.name,
|
|
511
|
-
label: t(type.title || type.name),
|
|
512
|
-
value: type.name
|
|
513
|
-
}));
|
|
514
|
-
}),
|
|
515
|
-
{
|
|
516
|
-
onSuccess: (types2) => {
|
|
517
|
-
setTypes(types2);
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
);
|
|
521
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(antd.Card, { bordered: false, children: /* @__PURE__ */ jsxRuntimeExports.jsx(AuthTypesContext.Provider, { value: { types }, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
522
|
-
client.SchemaComponent,
|
|
523
|
-
{
|
|
524
|
-
schema: authenticatorsSchema,
|
|
525
|
-
components: { AddNew, Options: Options$1 },
|
|
526
|
-
scope: { types, useValuesFromOptions, useCanNotDelete, t }
|
|
527
|
-
}
|
|
528
|
-
) }) });
|
|
529
|
-
};
|
|
530
|
-
const passwordForm = {
|
|
531
|
-
type: "object",
|
|
532
|
-
name: "passwordForm",
|
|
533
|
-
"x-component": "FormV2",
|
|
534
|
-
properties: {
|
|
535
|
-
account: {
|
|
536
|
-
type: "string",
|
|
537
|
-
"x-component": "Input",
|
|
538
|
-
"x-validator": `{{(value) => {
|
|
1
|
+
(function(o,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("antd"),require("react"),require("@formily/shared"),require("react-i18next"),require("@ant-design/icons"),require("@formily/react")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","antd","react","@formily/shared","react-i18next","@ant-design/icons","@formily/react"],e):(o=typeof globalThis!="undefined"?globalThis:o||self,e(o["@nocobase/plugin-auth"]={},o["@nocobase/client"],o.jsxRuntime,o.antd,o.react,o["@formily/shared"],o["react-i18next"],o["@ant-design/icons"],o["@formily/react"]))})(this,function(o,e,t,l,p,g,y,d,a){"use strict";var H=Object.defineProperty,J=Object.defineProperties;var Q=Object.getOwnPropertyDescriptors;var F=Object.getOwnPropertySymbols;var W=Object.prototype.hasOwnProperty,X=Object.prototype.propertyIsEnumerable;var P=(o,e,t)=>e in o?H(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,C=(o,e)=>{for(var t in e||(e={}))W.call(e,t)&&P(o,t,e[t]);if(F)for(var t of F(e))X.call(e,t)&&P(o,t,e[t]);return o},A=(o,e)=>J(o,Q(e));var b=(o,e,t)=>new Promise((l,p)=>{var g=a=>{try{d(t.next(a))}catch(x){p(x)}},y=a=>{try{d(t.throw(a))}catch(x){p(x)}},d=a=>a.done?l(a.value):Promise.resolve(a.value).then(g,y);d((t=t.apply(o,e)).next())});const x=p.createContext({type:""}),S=p.createContext({types:[]}),I=()=>{const{types:n}=p.useContext(S);return n},w={name:"authenticators",sortable:!0,fields:[{name:"id",type:"string",interface:"id"},{interface:"input",type:"string",name:"name",uiSchema:{type:"string",title:'{{t("Auth UID")}}',"x-component":"Input",required:!0}},{interface:"input",type:"string",name:"authType",uiSchema:{type:"string",title:'{{t("Auth Type")}}',"x-component":"Select",dataSource:"{{ types }}",required:!0}},{interface:"input",type:"string",name:"title",uiSchema:{type:"string",title:'{{t("Title")}}',"x-component":"Input"}},{interface:"textarea",type:"string",name:"description",uiSchema:{type:"string",title:'{{t("Description")}}',"x-component":"Input"}},{type:"boolean",name:"enabled",uiSchema:{type:"boolean",title:'{{t("Enabled")}}',"x-component":"Checkbox"}}]},D={type:"object",properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues(n){const r=e.useActionContext(),{type:i}=p.useContext(x);return e.useRequest(()=>Promise.resolve({data:{name:`s_${g.uid()}`,authType:i}}),A(C({},n),{refreshDeps:[r.visible]}))}},title:'{{t("Add new")}}',properties:{name:{"x-component":"CollectionField","x-decorator":"FormItem"},authType:{"x-component":"CollectionField","x-decorator":"FormItem","x-component-props":{options:"{{ types }}"}},title:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"Options"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}},k={type:"void",name:"authenticators","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:w,resourceName:"authenticators",dragSort:!0,request:{resource:"authenticators",action:"list",params:{pageSize:50,sort:"sort",appends:[]}}},"x-component":"CollectionProvider","x-component-props":{collection:w},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"AddNew","x-component-props":{type:"primary"}}}},table:{type:"void","x-uid":"input","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}",useAction(){const n=e.useAPIClient(),{t:r}=y.useTranslation();return{move(c,s){return b(this,null,function*(){yield n.resource("authenticators").move({sourceId:c.id,targetId:s.id}),l.message.success(r("Saved successfully"),.2)})}}}},properties:{id:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{id:{type:"number","x-component":"CollectionField","x-read-pretty":!0}}},name:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},authType:{title:'{{t("Auth Type")}}',type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{authType:{type:"string","x-component":"Select","x-read-pretty":!0,enum:"{{ types }}"}}},title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},description:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{description:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{enabled:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{update:{type:"void",title:'{{t("Configure")}}',"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:"{{ cm.useValuesFromRecord }}"},title:'{{t("Configure")}}',properties:{name:{"x-component":"CollectionField","x-decorator":"FormItem"},authType:{"x-component":"CollectionField","x-decorator":"FormItem","x-component-props":{options:"{{ types }}"}},title:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"Options"},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"},useAction:"{{cm.useDestroyAction}}"},"x-disabled":"{{ useCanNotDelete() }}"}}}}}}}}},q=n=>{const r=e.useRecord(),i=e.useRequest(()=>Promise.resolve({data:C({},r.options)}),A(C({},n),{manual:!0})),{run:c}=i,s=e.useActionContext();return p.useEffect(()=>{s.visible&&c()},[s.visible,c]),i},j=a.observer(()=>{const n=a.useForm(),r=e.useRecord();return e.useOptionsComponent(n.values.authType||r.authType)}),$="auth";function h(){return y.useTranslation($)}const O=()=>{const{setVisible:n}=e.useActionContext();return{run(){return b(this,null,function*(){n(!1)})}}},V=()=>{const{t:n}=y.useTranslation(),[r,i]=p.useState(!1),[c,s]=p.useState(""),m=I(),v=m.map(u=>A(C({},u),{onClick:()=>{i(!0),s(u.value)}}));return t.jsx(e.ActionContextProvider,{value:{visible:r,setVisible:i},children:t.jsxs(x.Provider,{value:{type:c},children:[t.jsx(l.Dropdown,{menu:{items:v},children:t.jsxs(l.Button,{icon:t.jsx(d.PlusOutlined,{}),type:"primary",children:[n("Add new")," ",t.jsx(d.DownOutlined,{})]})}),t.jsx(e.SchemaComponent,{scope:{useCloseAction:O,types:m,setType:s},schema:D})]})})},B=()=>(e.useAsyncData(),!1),E=()=>{const{t:n}=h(),[r,i]=p.useState([]),c=e.useAPIClient();return e.useRequest(()=>c.resource("authenticators").listTypes().then(s=>{var v;return(((v=s==null?void 0:s.data)==null?void 0:v.data)||[]).map(u=>({key:u.name,label:n(u.title||u.name),value:u.name}))}),{onSuccess:s=>{i(s)}}),t.jsx(l.Card,{bordered:!1,children:t.jsx(S.Provider,{value:{types:r},children:t.jsx(e.SchemaComponent,{schema:k,components:{AddNew:V,Options:j},scope:{types:r,useValuesFromOptions:q,useCanNotDelete:B,t:n}})})})},L={type:"object",name:"passwordForm","x-component":"FormV2",properties:{account:{type:"string","x-component":"Input","x-validator":`{{(value) => {
|
|
539
2
|
if (!value) {
|
|
540
3
|
return t("Please enter your username or email");
|
|
541
4
|
}
|
|
@@ -546,209 +9,4 @@
|
|
|
546
9
|
} else {
|
|
547
10
|
return /^[^@.<>"'/]{2,16}$/.test(value) || t("Please enter a valid username");
|
|
548
11
|
}
|
|
549
|
-
}}}`,
|
|
550
|
-
"x-decorator": "FormItem",
|
|
551
|
-
"x-component-props": { placeholder: '{{t("Username/Email")}}', style: {} }
|
|
552
|
-
},
|
|
553
|
-
password: {
|
|
554
|
-
type: "string",
|
|
555
|
-
"x-component": "Password",
|
|
556
|
-
required: true,
|
|
557
|
-
"x-decorator": "FormItem",
|
|
558
|
-
"x-component-props": { placeholder: '{{t("Password")}}', style: {} }
|
|
559
|
-
},
|
|
560
|
-
actions: {
|
|
561
|
-
type: "void",
|
|
562
|
-
"x-component": "div",
|
|
563
|
-
properties: {
|
|
564
|
-
submit: {
|
|
565
|
-
title: '{{t("Sign in")}}',
|
|
566
|
-
type: "void",
|
|
567
|
-
"x-component": "Action",
|
|
568
|
-
"x-component-props": {
|
|
569
|
-
htmlType: "submit",
|
|
570
|
-
block: true,
|
|
571
|
-
type: "primary",
|
|
572
|
-
useAction: `{{ useBasicSignIn }}`,
|
|
573
|
-
style: { width: "100%" }
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
},
|
|
578
|
-
signup: {
|
|
579
|
-
type: "void",
|
|
580
|
-
"x-component": "Link",
|
|
581
|
-
"x-component-props": {
|
|
582
|
-
to: "{{ signupLink }}"
|
|
583
|
-
},
|
|
584
|
-
"x-content": '{{t("Create an account")}}',
|
|
585
|
-
"x-visible": "{{ allowSignUp }}"
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
};
|
|
589
|
-
const SigninPage = (props) => {
|
|
590
|
-
const { t } = useAuthTranslation();
|
|
591
|
-
const authenticator = props.authenticator;
|
|
592
|
-
const { authType, name, options } = authenticator;
|
|
593
|
-
const signupPages = require$$0.useContext(client.SignupPageContext);
|
|
594
|
-
const allowSignUp = !!signupPages[authType] && (options == null ? void 0 : options.allowSignup);
|
|
595
|
-
const signupLink = `/signup?authType=${authType}&name=${name}`;
|
|
596
|
-
const useBasicSignIn = () => {
|
|
597
|
-
return client.useSignIn(name);
|
|
598
|
-
};
|
|
599
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(client.SchemaComponent, { schema: passwordForm, scope: { useBasicSignIn, allowSignUp, signupLink, t } });
|
|
600
|
-
};
|
|
601
|
-
const presetAuthType = "Email/Password";
|
|
602
|
-
const signupPageSchema = {
|
|
603
|
-
type: "object",
|
|
604
|
-
name: shared.uid(),
|
|
605
|
-
"x-component": "FormV2",
|
|
606
|
-
properties: {
|
|
607
|
-
username: {
|
|
608
|
-
type: "string",
|
|
609
|
-
required: true,
|
|
610
|
-
"x-component": "Input",
|
|
611
|
-
"x-validator": { username: true },
|
|
612
|
-
"x-decorator": "FormItem",
|
|
613
|
-
"x-component-props": { placeholder: '{{t("Username")}}', style: {} }
|
|
614
|
-
},
|
|
615
|
-
password: {
|
|
616
|
-
type: "string",
|
|
617
|
-
required: true,
|
|
618
|
-
"x-component": "Password",
|
|
619
|
-
"x-decorator": "FormItem",
|
|
620
|
-
"x-component-props": { placeholder: '{{t("Password")}}', checkStrength: true, style: {} },
|
|
621
|
-
"x-reactions": [
|
|
622
|
-
{
|
|
623
|
-
dependencies: [".confirm_password"],
|
|
624
|
-
fulfill: {
|
|
625
|
-
state: {
|
|
626
|
-
selfErrors: '{{$deps[0] && $self.value && $self.value !== $deps[0] ? t("Password mismatch") : ""}}'
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
]
|
|
631
|
-
},
|
|
632
|
-
confirm_password: {
|
|
633
|
-
type: "string",
|
|
634
|
-
required: true,
|
|
635
|
-
"x-component": "Password",
|
|
636
|
-
"x-decorator": "FormItem",
|
|
637
|
-
"x-component-props": { placeholder: '{{t("Confirm password")}}', style: {} },
|
|
638
|
-
"x-reactions": [
|
|
639
|
-
{
|
|
640
|
-
dependencies: [".password"],
|
|
641
|
-
fulfill: {
|
|
642
|
-
state: {
|
|
643
|
-
selfErrors: '{{$deps[0] && $self.value && $self.value !== $deps[0] ? t("Password mismatch") : ""}}'
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
]
|
|
648
|
-
},
|
|
649
|
-
actions: {
|
|
650
|
-
type: "void",
|
|
651
|
-
"x-component": "div",
|
|
652
|
-
properties: {
|
|
653
|
-
submit: {
|
|
654
|
-
title: '{{t("Sign up")}}',
|
|
655
|
-
type: "void",
|
|
656
|
-
"x-component": "Action",
|
|
657
|
-
"x-component-props": {
|
|
658
|
-
block: true,
|
|
659
|
-
type: "primary",
|
|
660
|
-
htmlType: "submit",
|
|
661
|
-
useAction: "{{ useBasicSignup }}",
|
|
662
|
-
style: { width: "100%" }
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
},
|
|
667
|
-
link: {
|
|
668
|
-
type: "void",
|
|
669
|
-
"x-component": "div",
|
|
670
|
-
properties: {
|
|
671
|
-
link: {
|
|
672
|
-
type: "void",
|
|
673
|
-
"x-component": "Link",
|
|
674
|
-
"x-component-props": { to: "/signin" },
|
|
675
|
-
"x-content": '{{t("Log in with an existing account")}}'
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
};
|
|
681
|
-
const SignupPage = (props) => {
|
|
682
|
-
const { t } = useAuthTranslation();
|
|
683
|
-
const useBasicSignup = () => {
|
|
684
|
-
return client.useSignup({ authenticator: props.name });
|
|
685
|
-
};
|
|
686
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(client.SchemaComponent, { schema: signupPageSchema, scope: { useBasicSignup, t } });
|
|
687
|
-
};
|
|
688
|
-
const Options = () => {
|
|
689
|
-
const { t } = useAuthTranslation();
|
|
690
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
691
|
-
client.SchemaComponent,
|
|
692
|
-
{
|
|
693
|
-
scope: { t },
|
|
694
|
-
components: { Alert: antd.Alert },
|
|
695
|
-
schema: {
|
|
696
|
-
type: "object",
|
|
697
|
-
properties: {
|
|
698
|
-
public: {
|
|
699
|
-
type: "object",
|
|
700
|
-
properties: {
|
|
701
|
-
allowSignup: {
|
|
702
|
-
"x-decorator": "FormItem",
|
|
703
|
-
type: "boolean",
|
|
704
|
-
title: '{{t("Allow to sign up")}}',
|
|
705
|
-
"x-component": "Checkbox",
|
|
706
|
-
"x-component-props": {
|
|
707
|
-
defaultChecked: true
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
},
|
|
712
|
-
notice: {
|
|
713
|
-
type: "void",
|
|
714
|
-
"x-component": "Alert",
|
|
715
|
-
"x-component-props": {
|
|
716
|
-
showIcon: true,
|
|
717
|
-
message: '{{t("The authentication allows users to sign in via username or email.")}}'
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
);
|
|
724
|
-
};
|
|
725
|
-
const AuthProvider = (props) => {
|
|
726
|
-
const { t } = useAuthTranslation();
|
|
727
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
728
|
-
client.SettingsCenterProvider,
|
|
729
|
-
{
|
|
730
|
-
settings: {
|
|
731
|
-
auth: {
|
|
732
|
-
title: t("Authentication"),
|
|
733
|
-
icon: "LoginOutlined",
|
|
734
|
-
tabs: {
|
|
735
|
-
authenticators: {
|
|
736
|
-
title: t("Authenticators"),
|
|
737
|
-
component: () => /* @__PURE__ */ jsxRuntimeExports.jsx(Authenticator, {})
|
|
738
|
-
}
|
|
739
|
-
}
|
|
740
|
-
}
|
|
741
|
-
},
|
|
742
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsx(client.OptionsComponentProvider, { authType: presetAuthType, component: Options, children: /* @__PURE__ */ jsxRuntimeExports.jsx(client.SigninPageProvider, { authType: presetAuthType, tabTitle: t("Sign in via password"), component: SigninPage, children: /* @__PURE__ */ jsxRuntimeExports.jsx(client.SignupPageProvider, { authType: presetAuthType, component: SignupPage, children: props.children }) }) })
|
|
743
|
-
}
|
|
744
|
-
);
|
|
745
|
-
};
|
|
746
|
-
class AuthPlugin extends client.Plugin {
|
|
747
|
-
async load() {
|
|
748
|
-
this.app.use(AuthProvider);
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
exports2.AuthPlugin = AuthPlugin;
|
|
752
|
-
exports2.default = AuthPlugin;
|
|
753
|
-
Object.defineProperties(exports2, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
754
|
-
});
|
|
12
|
+
}}}`,"x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Username/Email")}}',style:{}}},password:{type:"string","x-component":"Password",required:!0,"x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Password")}}',style:{}}},actions:{type:"void","x-component":"div",properties:{submit:{title:'{{t("Sign in")}}',type:"void","x-component":"Action","x-component-props":{htmlType:"submit",block:!0,type:"primary",useAction:"{{ useBasicSignIn }}",style:{width:"100%"}}}}},signup:{type:"void","x-component":"Link","x-component-props":{to:"{{ signupLink }}"},"x-content":'{{t("Create an account")}}',"x-visible":"{{ allowSignUp }}"}}},N=n=>{const{t:r}=h(),i=n.authenticator,{authType:c,name:s,options:m}=i,u=!!p.useContext(e.SignupPageContext)[c]&&(m==null?void 0:m.allowSignup),K=`/signup?authType=${c}&name=${s}`,G=()=>e.useSignIn(s);return t.jsx(e.SchemaComponent,{schema:L,scope:{useBasicSignIn:G,allowSignUp:u,signupLink:K,t:r}})},f="Email/Password",U={type:"object",name:g.uid(),"x-component":"FormV2",properties:{username:{type:"string",required:!0,"x-component":"Input","x-validator":{username:!0},"x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Username")}}',style:{}}},password:{type:"string",required:!0,"x-component":"Password","x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Password")}}',checkStrength:!0,style:{}},"x-reactions":[{dependencies:[".confirm_password"],fulfill:{state:{selfErrors:'{{$deps[0] && $self.value && $self.value !== $deps[0] ? t("Password mismatch") : ""}}'}}}]},confirm_password:{type:"string",required:!0,"x-component":"Password","x-decorator":"FormItem","x-component-props":{placeholder:'{{t("Confirm password")}}',style:{}},"x-reactions":[{dependencies:[".password"],fulfill:{state:{selfErrors:'{{$deps[0] && $self.value && $self.value !== $deps[0] ? t("Password mismatch") : ""}}'}}}]},actions:{type:"void","x-component":"div",properties:{submit:{title:'{{t("Sign up")}}',type:"void","x-component":"Action","x-component-props":{block:!0,type:"primary",htmlType:"submit",useAction:"{{ useBasicSignup }}",style:{width:"100%"}}}}},link:{type:"void","x-component":"div",properties:{link:{type:"void","x-component":"Link","x-component-props":{to:"/signin"},"x-content":'{{t("Log in with an existing account")}}'}}}}},_=n=>{const{t:r}=h(),i=()=>e.useSignup({authenticator:n.name});return t.jsx(e.SchemaComponent,{schema:U,scope:{useBasicSignup:i,t:r}})},M=()=>{const{t:n}=h();return t.jsx(e.SchemaComponent,{scope:{t:n},components:{Alert:l.Alert},schema:{type:"object",properties:{public:{type:"object",properties:{allowSignup:{"x-decorator":"FormItem",type:"boolean",title:'{{t("Allow to sign up")}}',"x-component":"Checkbox","x-component-props":{defaultChecked:!0}}}},notice:{type:"void","x-component":"Alert","x-component-props":{showIcon:!0,message:'{{t("The authentication allows users to sign in via username or email.")}}'}}}}})},z=n=>{const{t:r}=h();return t.jsx(e.SettingsCenterProvider,{settings:{auth:{title:r("Authentication"),icon:"LoginOutlined",tabs:{authenticators:{title:r("Authenticators"),component:()=>t.jsx(E,{})}}}},children:t.jsx(e.OptionsComponentProvider,{authType:f,component:M,children:t.jsx(e.SigninPageProvider,{authType:f,tabTitle:r("Sign in via password"),component:N,children:t.jsx(e.SignupPageProvider,{authType:f,component:_,children:n.children})})})})};class T extends e.Plugin{load(){return b(this,null,function*(){this.app.use(z)})}}o.AuthPlugin=T,o.default=T,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|