@nocobase/plugin-auth 0.10.0-alpha.2
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/README.md +117 -0
- package/client.d.ts +3 -0
- package/client.js +65 -0
- package/lib/client/basic/Options.d.ts +2 -0
- package/lib/client/basic/Options.js +51 -0
- package/lib/client/basic/SigninPage.d.ts +6 -0
- package/lib/client/basic/SigninPage.js +100 -0
- package/lib/client/basic/SignupPage.d.ts +5 -0
- package/lib/client/basic/SignupPage.js +131 -0
- package/lib/client/index.d.ts +3 -0
- package/lib/client/index.js +56 -0
- package/lib/client/locale/index.d.ts +2 -0
- package/lib/client/locale/index.js +19 -0
- package/lib/client/locale/zh-CN.d.ts +9 -0
- package/lib/client/locale/zh-CN.js +16 -0
- package/lib/client/settings/Authenticator.d.ts +2 -0
- package/lib/client/settings/Authenticator.js +159 -0
- package/lib/client/settings/Options.d.ts +3 -0
- package/lib/client/settings/Options.js +56 -0
- package/lib/client/settings/authType.d.ts +16 -0
- package/lib/client/settings/authType.js +27 -0
- package/lib/client/settings/schemas/authenticators.d.ts +3 -0
- package/lib/client/settings/schemas/authenticators.js +438 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +20 -0
- package/lib/preset.d.ts +3 -0
- package/lib/preset.js +12 -0
- package/lib/server/actions/auth.d.ts +8 -0
- package/lib/server/actions/auth.js +51 -0
- package/lib/server/actions/authenticators.d.ts +8 -0
- package/lib/server/actions/authenticators.js +131 -0
- package/lib/server/basic-auth.d.ts +10 -0
- package/lib/server/basic-auth.js +183 -0
- package/lib/server/collections/authenticators.d.ts +6 -0
- package/lib/server/collections/authenticators.js +93 -0
- package/lib/server/collections/users-authenticators.d.ts +7 -0
- package/lib/server/collections/users-authenticators.js +75 -0
- package/lib/server/index.d.ts +2 -0
- package/lib/server/index.js +20 -0
- package/lib/server/locale/en-US.d.ts +9 -0
- package/lib/server/locale/en-US.js +15 -0
- package/lib/server/locale/index.d.ts +3 -0
- package/lib/server/locale/index.js +27 -0
- package/lib/server/locale/ja-JP.d.ts +5 -0
- package/lib/server/locale/ja-JP.js +11 -0
- package/lib/server/locale/pt-BR.d.ts +9 -0
- package/lib/server/locale/pt-BR.js +15 -0
- package/lib/server/locale/zh-CN.d.ts +10 -0
- package/lib/server/locale/zh-CN.js +16 -0
- package/lib/server/migrations/20230506152253-basic-authenticator.d.ts +5 -0
- package/lib/server/migrations/20230506152253-basic-authenticator.js +40 -0
- package/lib/server/migrations/20230607174500-update-basic.d.ts +5 -0
- package/lib/server/migrations/20230607174500-update-basic.js +43 -0
- package/lib/server/model/authenticator.d.ts +6 -0
- package/lib/server/model/authenticator.js +72 -0
- package/lib/server/plugin.d.ts +11 -0
- package/lib/server/plugin.js +130 -0
- package/package.json +17 -0
- package/server.d.ts +3 -0
- package/server.js +65 -0
- package/src/client/basic/Options.tsx +31 -0
- package/src/client/basic/SigninPage.tsx +65 -0
- package/src/client/basic/SignupPage.tsx +91 -0
- package/src/client/index.tsx +41 -0
- package/src/client/locale/index.ts +7 -0
- package/src/client/locale/zh-CN.ts +10 -0
- package/src/client/settings/Authenticator.tsx +95 -0
- package/src/client/settings/Options.tsx +35 -0
- package/src/client/settings/authType.ts +18 -0
- package/src/client/settings/schemas/authenticators.ts +402 -0
- package/src/index.ts +1 -0
- package/src/preset.ts +4 -0
- package/src/server/__tests__/actions.test.ts +142 -0
- package/src/server/actions/auth.ts +20 -0
- package/src/server/actions/authenticators.ts +85 -0
- package/src/server/basic-auth.ts +128 -0
- package/src/server/collections/.gitkeep +0 -0
- package/src/server/collections/authenticators.ts +97 -0
- package/src/server/collections/users-authenticators.ts +73 -0
- package/src/server/index.ts +2 -0
- package/src/server/locale/en-US.ts +10 -0
- package/src/server/locale/index.ts +3 -0
- package/src/server/locale/ja-JP.ts +4 -0
- package/src/server/locale/pt-BR.ts +10 -0
- package/src/server/locale/zh-CN.ts +9 -0
- package/src/server/migrations/20230506152253-basic-authenticator.ts +22 -0
- package/src/server/migrations/20230607174500-update-basic.ts +25 -0
- package/src/server/model/authenticator.ts +48 -0
- package/src/server/plugin.ts +92 -0
package/README.md
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# Auth
|
|
2
|
+
|
|
3
|
+
提供基础认证功能和扩展认证器管理功能。
|
|
4
|
+
|
|
5
|
+
## 使用方法
|
|
6
|
+
|
|
7
|
+
### 认证器管理
|
|
8
|
+
页面:系统设置 - 认证
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
<img src="https://s2.loli.net/2023/05/15/NdriQZvBuE6hGRS.png" width="800px" />
|
|
12
|
+
|
|
13
|
+
#### 内置认证器
|
|
14
|
+
- 名称:basic
|
|
15
|
+
- 认证类型:邮箱密码登录
|
|
16
|
+
|
|
17
|
+
<img src="https://s2.loli.net/2023/05/15/HC4gtx9fQPrqvac.png" width="300px" />
|
|
18
|
+
|
|
19
|
+
<img src="https://s2.loli.net/2023/05/15/fcLqypdhOxnksbg.png" width="300px" />
|
|
20
|
+
|
|
21
|
+
#### 增加认证器
|
|
22
|
+
Add new - 选择认证类型
|
|
23
|
+
|
|
24
|
+
<img src="https://s2.loli.net/2023/05/15/CR7UTDt2WzbEfgs.png" width="300px" />
|
|
25
|
+
|
|
26
|
+
#### 启用/禁用
|
|
27
|
+
Actions - Edit - 勾选/取消Enabled
|
|
28
|
+
|
|
29
|
+
<img src="https://s2.loli.net/2023/05/15/2utpSHly9fzCKX5.png" width="400px" />
|
|
30
|
+
|
|
31
|
+
#### 配置认证器
|
|
32
|
+
Actions - Edit
|
|
33
|
+
|
|
34
|
+
## 开发一个登录插件
|
|
35
|
+
### 接口
|
|
36
|
+
Nocobase内核提供了扩展登录方式的接入和管理。扩展登录插件的核心逻辑处理,需要继承内核的`Auth`类,并对相应的标准接口进行实现。
|
|
37
|
+
参考`core/auth/auth.ts`
|
|
38
|
+
|
|
39
|
+
```TypeScript
|
|
40
|
+
import { Auth } from '@nocobase/auth';
|
|
41
|
+
|
|
42
|
+
class CustomAuth extends Auth {
|
|
43
|
+
set user(user) {}
|
|
44
|
+
get user() {}
|
|
45
|
+
|
|
46
|
+
async check() {}
|
|
47
|
+
async signIn() {}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
多数情况下,扩展的用户登录方式也将沿用现有的jwt逻辑来生成用户访问API的凭证,插件也可以继承`BaseAuth`类以便复用部分逻辑代码,如`check`, `signIn`接口。
|
|
52
|
+
|
|
53
|
+
```TypeScript
|
|
54
|
+
import { BaseAuth } from '@nocobase/auth';
|
|
55
|
+
|
|
56
|
+
class CustomAuth extends BaseAuth {
|
|
57
|
+
constructor(config: AuthConfig) {
|
|
58
|
+
const userCollection = config.ctx.db.getCollection('users');
|
|
59
|
+
super({ ...config, userCollection });
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async validate() {}
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### 用户数据
|
|
67
|
+
|
|
68
|
+
`@nocobase/plugin-auth`插件提供了`usersAuthenticators`表来建立users和authenticators,即用户和认证方式的关联。
|
|
69
|
+
通常情况下,扩展登录方式用`users`和`usersAuthenticators`来存储相应的用户数据即可,特殊情况下才需要自己新增Collection.
|
|
70
|
+
`users`存储的是最基础的用户数据,邮箱、昵称和密码。
|
|
71
|
+
`usersAuthenticators`存储扩展登录方式数据
|
|
72
|
+
- uuid: 该种认证方式的用户唯一标识,如手机号、微信openid等
|
|
73
|
+
- meta: JSON字段,其他需要保存的信息
|
|
74
|
+
- userId: 用户id
|
|
75
|
+
- authenticator:认证器名字
|
|
76
|
+
|
|
77
|
+
对于用户操作,`Authenticator`模型也提供了几个封装的方法,可以在`CustomAuth`类中通过`this.authenticator[方法名]`使用:
|
|
78
|
+
- `findUser(uuid: string): UserModel` - 查询用户
|
|
79
|
+
- `newUser(uuid: string, values?: any): UserModel` - 创建新用户
|
|
80
|
+
- `findOrCreateUser(uuid: string, userValues?: any): UserModel` - 查找或创建新用户
|
|
81
|
+
|
|
82
|
+
### 注册
|
|
83
|
+
扩展的登录方式需要向内核注册。
|
|
84
|
+
```TypeScript
|
|
85
|
+
async load() {
|
|
86
|
+
this.app.authManager.registerTypes('custom-auth-type', {
|
|
87
|
+
auth: CustomAuth,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### 客户端API
|
|
93
|
+
#### OptionsComponentProvider
|
|
94
|
+
可供用户配置的认证器配置项
|
|
95
|
+
- authType 认证方式
|
|
96
|
+
- component 配置组件
|
|
97
|
+
```TypeScript
|
|
98
|
+
<OptionsComponentProvider authType="custom-auth-type" component={Options} />
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
`Options`组件使用的值是`authenticator`的`options`字段,如果有需要暴露在前端的配置,应该放在`options.public`字段中。`authenticators:publicList`接口会返回`options.public`字段的值。
|
|
102
|
+
|
|
103
|
+
#### SigninPageProvider
|
|
104
|
+
自定义登录页界面
|
|
105
|
+
- authType 认证方式
|
|
106
|
+
- tabTitle 登录页tab标题
|
|
107
|
+
- component 登录页组件
|
|
108
|
+
|
|
109
|
+
#### SignupPageProvider
|
|
110
|
+
自定义注册页界面
|
|
111
|
+
- authType 认证方式
|
|
112
|
+
- component 注册页组件
|
|
113
|
+
|
|
114
|
+
#### SigninPageExtensionProvider
|
|
115
|
+
自定义登录页下方的扩展内容
|
|
116
|
+
- authType 认证方式
|
|
117
|
+
- component 扩展组件
|
package/client.d.ts
ADDED
package/client.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
4
|
+
if (typeof WeakMap !== 'function') return null;
|
|
5
|
+
var cacheBabelInterop = new WeakMap();
|
|
6
|
+
var cacheNodeInterop = new WeakMap();
|
|
7
|
+
return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) {
|
|
8
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
9
|
+
})(nodeInterop);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function _interopRequireWildcard(obj, nodeInterop) {
|
|
13
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
14
|
+
return obj;
|
|
15
|
+
}
|
|
16
|
+
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
|
17
|
+
return { default: obj };
|
|
18
|
+
}
|
|
19
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
20
|
+
if (cache && cache.has(obj)) {
|
|
21
|
+
return cache.get(obj);
|
|
22
|
+
}
|
|
23
|
+
var newObj = {};
|
|
24
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
25
|
+
for (var key in obj) {
|
|
26
|
+
if (key !== 'default' && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
27
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
28
|
+
if (desc && (desc.get || desc.set)) {
|
|
29
|
+
Object.defineProperty(newObj, key, desc);
|
|
30
|
+
} else {
|
|
31
|
+
newObj[key] = obj[key];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
newObj.default = obj;
|
|
36
|
+
if (cache) {
|
|
37
|
+
cache.set(obj, newObj);
|
|
38
|
+
}
|
|
39
|
+
return newObj;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
var _index = _interopRequireWildcard(require('./lib/client'));
|
|
43
|
+
|
|
44
|
+
Object.defineProperty(exports, '__esModule', {
|
|
45
|
+
value: true,
|
|
46
|
+
});
|
|
47
|
+
var _exportNames = {};
|
|
48
|
+
Object.defineProperty(exports, 'default', {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function get() {
|
|
51
|
+
return _index.default;
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
Object.keys(_index).forEach(function (key) {
|
|
56
|
+
if (key === 'default' || key === '__esModule') return;
|
|
57
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
58
|
+
if (key in exports && exports[key] === _index[key]) return;
|
|
59
|
+
Object.defineProperty(exports, key, {
|
|
60
|
+
enumerable: true,
|
|
61
|
+
get: function get() {
|
|
62
|
+
return _index[key];
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Options = void 0;
|
|
7
|
+
function _client() {
|
|
8
|
+
const data = require("@nocobase/client");
|
|
9
|
+
_client = function _client() {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function _react() {
|
|
15
|
+
const data = _interopRequireDefault(require("react"));
|
|
16
|
+
_react = function _react() {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
var _locale = require("../locale");
|
|
22
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
+
const Options = () => {
|
|
24
|
+
const _useAuthTranslation = (0, _locale.useAuthTranslation)(),
|
|
25
|
+
t = _useAuthTranslation.t;
|
|
26
|
+
return _react().default.createElement(_client().SchemaComponent, {
|
|
27
|
+
scope: {
|
|
28
|
+
t
|
|
29
|
+
},
|
|
30
|
+
schema: {
|
|
31
|
+
type: 'object',
|
|
32
|
+
properties: {
|
|
33
|
+
public: {
|
|
34
|
+
type: 'object',
|
|
35
|
+
properties: {
|
|
36
|
+
allowSignup: {
|
|
37
|
+
'x-decorator': 'FormItem',
|
|
38
|
+
type: 'boolean',
|
|
39
|
+
title: '{{t("Allow to sign up")}}',
|
|
40
|
+
'x-component': 'Checkbox',
|
|
41
|
+
'x-component-props': {
|
|
42
|
+
defaultChecked: true
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
exports.Options = Options;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
function _client() {
|
|
8
|
+
const data = require("@nocobase/client");
|
|
9
|
+
_client = function _client() {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function _react() {
|
|
15
|
+
const data = _interopRequireWildcard(require("react"));
|
|
16
|
+
_react = function _react() {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
22
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
|
+
const passwordForm = {
|
|
24
|
+
type: 'object',
|
|
25
|
+
name: 'passwordForm',
|
|
26
|
+
'x-component': 'FormV2',
|
|
27
|
+
properties: {
|
|
28
|
+
email: {
|
|
29
|
+
type: 'string',
|
|
30
|
+
required: true,
|
|
31
|
+
'x-component': 'Input',
|
|
32
|
+
'x-validator': 'email',
|
|
33
|
+
'x-decorator': 'FormItem',
|
|
34
|
+
'x-component-props': {
|
|
35
|
+
placeholder: '{{t("Email")}}',
|
|
36
|
+
style: {}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
password: {
|
|
40
|
+
type: 'string',
|
|
41
|
+
'x-component': 'Password',
|
|
42
|
+
required: true,
|
|
43
|
+
'x-decorator': 'FormItem',
|
|
44
|
+
'x-component-props': {
|
|
45
|
+
placeholder: '{{t("Password")}}',
|
|
46
|
+
style: {}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
actions: {
|
|
50
|
+
type: 'void',
|
|
51
|
+
'x-component': 'div',
|
|
52
|
+
properties: {
|
|
53
|
+
submit: {
|
|
54
|
+
title: '{{t("Sign in")}}',
|
|
55
|
+
type: 'void',
|
|
56
|
+
'x-component': 'Action',
|
|
57
|
+
'x-component-props': {
|
|
58
|
+
htmlType: 'submit',
|
|
59
|
+
block: true,
|
|
60
|
+
type: 'primary',
|
|
61
|
+
useAction: `{{ useBasicSignIn }}`,
|
|
62
|
+
style: {
|
|
63
|
+
width: '100%'
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
signup: {
|
|
70
|
+
type: 'void',
|
|
71
|
+
'x-component': 'Link',
|
|
72
|
+
'x-component-props': {
|
|
73
|
+
to: '{{ signupLink }}'
|
|
74
|
+
},
|
|
75
|
+
'x-content': '{{t("Create an account")}}',
|
|
76
|
+
'x-visible': '{{ allowSignUp }}'
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
var _default = props => {
|
|
81
|
+
const authenticator = props.authenticator;
|
|
82
|
+
const authType = authenticator.authType,
|
|
83
|
+
name = authenticator.name,
|
|
84
|
+
options = authenticator.options;
|
|
85
|
+
const signupPages = (0, _react().useContext)(_client().SignupPageContext);
|
|
86
|
+
const allowSignUp = !!signupPages[authType] && (options === null || options === void 0 ? void 0 : options.allowSignup);
|
|
87
|
+
const signupLink = `/signup?authType=${authType}&name=${name}`;
|
|
88
|
+
const useBasicSignIn = () => {
|
|
89
|
+
return (0, _client().useSignIn)(name);
|
|
90
|
+
};
|
|
91
|
+
return _react().default.createElement(_client().SchemaComponent, {
|
|
92
|
+
schema: passwordForm,
|
|
93
|
+
scope: {
|
|
94
|
+
useBasicSignIn,
|
|
95
|
+
allowSignUp,
|
|
96
|
+
signupLink
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
exports.default = _default;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
function _client() {
|
|
8
|
+
const data = require("@nocobase/client");
|
|
9
|
+
_client = function _client() {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function _react() {
|
|
15
|
+
const data = _interopRequireDefault(require("react"));
|
|
16
|
+
_react = function _react() {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
function _shared() {
|
|
22
|
+
const data = require("@formily/shared");
|
|
23
|
+
_shared = function _shared() {
|
|
24
|
+
return data;
|
|
25
|
+
};
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
|
+
const signupPageSchema = {
|
|
30
|
+
type: 'object',
|
|
31
|
+
name: (0, _shared().uid)(),
|
|
32
|
+
'x-component': 'FormV2',
|
|
33
|
+
properties: {
|
|
34
|
+
email: {
|
|
35
|
+
type: 'string',
|
|
36
|
+
required: true,
|
|
37
|
+
'x-component': 'Input',
|
|
38
|
+
'x-validator': 'email',
|
|
39
|
+
'x-decorator': 'FormItem',
|
|
40
|
+
'x-component-props': {
|
|
41
|
+
placeholder: '{{t("Email")}}',
|
|
42
|
+
style: {}
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
password: {
|
|
46
|
+
type: 'string',
|
|
47
|
+
required: true,
|
|
48
|
+
'x-component': 'Password',
|
|
49
|
+
'x-decorator': 'FormItem',
|
|
50
|
+
'x-component-props': {
|
|
51
|
+
placeholder: '{{t("Password")}}',
|
|
52
|
+
checkStrength: true,
|
|
53
|
+
style: {}
|
|
54
|
+
},
|
|
55
|
+
'x-reactions': [{
|
|
56
|
+
dependencies: ['.confirm_password'],
|
|
57
|
+
fulfill: {
|
|
58
|
+
state: {
|
|
59
|
+
selfErrors: '{{$deps[0] && $self.value && $self.value !== $deps[0] ? t("Password mismatch") : ""}}'
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}]
|
|
63
|
+
},
|
|
64
|
+
confirm_password: {
|
|
65
|
+
type: 'string',
|
|
66
|
+
required: true,
|
|
67
|
+
'x-component': 'Password',
|
|
68
|
+
'x-decorator': 'FormItem',
|
|
69
|
+
'x-component-props': {
|
|
70
|
+
placeholder: '{{t("Confirm password")}}',
|
|
71
|
+
style: {}
|
|
72
|
+
},
|
|
73
|
+
'x-reactions': [{
|
|
74
|
+
dependencies: ['.password'],
|
|
75
|
+
fulfill: {
|
|
76
|
+
state: {
|
|
77
|
+
selfErrors: '{{$deps[0] && $self.value && $self.value !== $deps[0] ? t("Password mismatch") : ""}}'
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}]
|
|
81
|
+
},
|
|
82
|
+
actions: {
|
|
83
|
+
type: 'void',
|
|
84
|
+
'x-component': 'div',
|
|
85
|
+
properties: {
|
|
86
|
+
submit: {
|
|
87
|
+
title: '{{t("Sign up")}}',
|
|
88
|
+
type: 'void',
|
|
89
|
+
'x-component': 'Action',
|
|
90
|
+
'x-component-props': {
|
|
91
|
+
block: true,
|
|
92
|
+
type: 'primary',
|
|
93
|
+
htmlType: 'submit',
|
|
94
|
+
useAction: '{{ useBasicSignup }}',
|
|
95
|
+
style: {
|
|
96
|
+
width: '100%'
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
link: {
|
|
103
|
+
type: 'void',
|
|
104
|
+
'x-component': 'div',
|
|
105
|
+
properties: {
|
|
106
|
+
link: {
|
|
107
|
+
type: 'void',
|
|
108
|
+
'x-component': 'Link',
|
|
109
|
+
'x-component-props': {
|
|
110
|
+
to: '/signin'
|
|
111
|
+
},
|
|
112
|
+
'x-content': '{{t("Log in with an existing account")}}'
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
var _default = props => {
|
|
119
|
+
const useBasicSignup = () => {
|
|
120
|
+
return (0, _client().useSignup)({
|
|
121
|
+
authenticator: props.name
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
return _react().default.createElement(_client().SchemaComponent, {
|
|
125
|
+
schema: signupPageSchema,
|
|
126
|
+
scope: {
|
|
127
|
+
useBasicSignup
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
exports.default = _default;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
function _client() {
|
|
8
|
+
const data = require("@nocobase/client");
|
|
9
|
+
_client = function _client() {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function _react() {
|
|
15
|
+
const data = _interopRequireDefault(require("react"));
|
|
16
|
+
_react = function _react() {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
var _Authenticator = require("./settings/Authenticator");
|
|
22
|
+
var _SigninPage = _interopRequireDefault(require("./basic/SigninPage"));
|
|
23
|
+
var _preset = require("../preset");
|
|
24
|
+
var _SignupPage = _interopRequireDefault(require("./basic/SignupPage"));
|
|
25
|
+
var _locale = require("./locale");
|
|
26
|
+
var _Options = require("./basic/Options");
|
|
27
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
28
|
+
var _default = props => {
|
|
29
|
+
const _useAuthTranslation = (0, _locale.useAuthTranslation)(),
|
|
30
|
+
t = _useAuthTranslation.t;
|
|
31
|
+
return _react().default.createElement(_client().SettingsCenterProvider, {
|
|
32
|
+
settings: {
|
|
33
|
+
auth: {
|
|
34
|
+
title: t('Authentication'),
|
|
35
|
+
icon: 'LoginOutlined',
|
|
36
|
+
tabs: {
|
|
37
|
+
authenticators: {
|
|
38
|
+
title: t('Authenticators'),
|
|
39
|
+
component: () => _react().default.createElement(_Authenticator.Authenticator, null)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}, _react().default.createElement(_client().OptionsComponentProvider, {
|
|
45
|
+
authType: _preset.presetAuthType,
|
|
46
|
+
component: _Options.Options
|
|
47
|
+
}, _react().default.createElement(_client().SigninPageProvider, {
|
|
48
|
+
authType: _preset.presetAuthType,
|
|
49
|
+
tabTitle: t('Sign in via email'),
|
|
50
|
+
component: _SigninPage.default
|
|
51
|
+
}, _react().default.createElement(_client().SignupPageProvider, {
|
|
52
|
+
authType: _preset.presetAuthType,
|
|
53
|
+
component: _SignupPage.default
|
|
54
|
+
}, props.children))));
|
|
55
|
+
};
|
|
56
|
+
exports.default = _default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.NAMESPACE = void 0;
|
|
7
|
+
exports.useAuthTranslation = useAuthTranslation;
|
|
8
|
+
function _reactI18next() {
|
|
9
|
+
const data = require("react-i18next");
|
|
10
|
+
_reactI18next = function _reactI18next() {
|
|
11
|
+
return data;
|
|
12
|
+
};
|
|
13
|
+
return data;
|
|
14
|
+
}
|
|
15
|
+
const NAMESPACE = 'auth';
|
|
16
|
+
exports.NAMESPACE = NAMESPACE;
|
|
17
|
+
function useAuthTranslation() {
|
|
18
|
+
return (0, _reactI18next().useTranslation)(NAMESPACE);
|
|
19
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
const locale = {
|
|
8
|
+
'Auth Type': '认证类型',
|
|
9
|
+
Authenticators: '认证器',
|
|
10
|
+
Authentication: '用户认证',
|
|
11
|
+
'Sign in via email': '邮箱登录',
|
|
12
|
+
'Not allowed to sign up': '禁止注册',
|
|
13
|
+
'Allow to sign up': '允许注册'
|
|
14
|
+
};
|
|
15
|
+
var _default = locale;
|
|
16
|
+
exports.default = _default;
|