@nocobase/plugin-auth 0.11.1-alpha.4 → 0.12.0-alpha.1
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/client.d.ts +2 -2
- package/client.js +1 -1
- package/dist/client/index.js +729 -0
- package/dist/index.js +20 -0
- package/dist/locale/zh-CN.js +20 -0
- package/dist/node_modules/cron/LICENSE +8 -0
- package/dist/node_modules/cron/lib/cron.js +1 -0
- package/dist/node_modules/cron/lib/job.js +215 -0
- package/dist/node_modules/cron/lib/time.js +817 -0
- package/dist/node_modules/cron/package.json +1 -0
- package/{lib → dist}/preset.d.ts +1 -1
- package/dist/preset.js +11 -0
- package/dist/server/actions/auth.js +22 -0
- package/dist/server/actions/authenticators.js +83 -0
- package/{src/server/basic-auth.ts → dist/server/basic-auth.js} +41 -42
- package/dist/server/collections/authenticators.js +97 -0
- package/dist/server/collections/token-blacklist.js +21 -0
- package/dist/server/collections/users-authenticators.js +71 -0
- package/dist/server/index.js +21 -0
- package/dist/server/locale/en-US.js +12 -0
- package/dist/server/locale/fr-FR.js +12 -0
- package/dist/server/locale/index.js +26 -0
- package/dist/server/locale/ja-JP.js +8 -0
- package/dist/server/locale/pt-BR.js +12 -0
- package/dist/server/locale/zh-CN.js +13 -0
- package/dist/server/migrations/20230506152253-basic-authenticator.js +26 -0
- package/dist/server/migrations/20230607174500-update-basic.js +29 -0
- package/{src/server/model/authenticator.ts → dist/server/model/authenticator.js} +19 -19
- package/dist/server/plugin.js +93 -0
- package/dist/server/token-blacklist.js +62 -0
- package/package.json +17 -28
- package/server.d.ts +2 -2
- package/server.js +1 -1
- package/lib/client/AuthProvider.js +0 -56
- package/lib/client/basic/Options.js +0 -51
- package/lib/client/basic/SigninPage.js +0 -100
- package/lib/client/basic/SignupPage.js +0 -131
- package/lib/client/index.js +0 -27
- package/lib/client/locale/index.js +0 -19
- package/lib/client/settings/Authenticator.js +0 -159
- package/lib/client/settings/Options.js +0 -56
- package/lib/client/settings/authType.js +0 -27
- package/lib/client/settings/schemas/authenticators.js +0 -438
- package/lib/index.js +0 -20
- package/lib/locale/zh-CN.js +0 -23
- package/lib/preset.js +0 -12
- package/lib/server/actions/auth.js +0 -51
- package/lib/server/actions/authenticators.js +0 -131
- package/lib/server/basic-auth.js +0 -183
- package/lib/server/collections/authenticators.js +0 -94
- package/lib/server/collections/token-blacklist.js +0 -21
- package/lib/server/collections/users-authenticators.js +0 -75
- package/lib/server/index.js +0 -20
- package/lib/server/locale/en-US.js +0 -15
- package/lib/server/locale/fr-FR.js +0 -15
- package/lib/server/locale/index.js +0 -27
- package/lib/server/locale/ja-JP.js +0 -11
- package/lib/server/locale/pt-BR.js +0 -15
- package/lib/server/locale/zh-CN.js +0 -16
- package/lib/server/migrations/20230506152253-basic-authenticator.js +0 -40
- package/lib/server/migrations/20230607174500-update-basic.js +0 -43
- package/lib/server/model/authenticator.js +0 -72
- package/lib/server/plugin.js +0 -129
- package/lib/server/token-blacklist.js +0 -82
- package/src/client/AuthProvider.tsx +0 -41
- package/src/client/basic/Options.tsx +0 -31
- package/src/client/basic/SigninPage.tsx +0 -65
- package/src/client/basic/SignupPage.tsx +0 -91
- package/src/client/index.tsx +0 -10
- package/src/client/locale/index.ts +0 -7
- package/src/client/settings/Authenticator.tsx +0 -95
- package/src/client/settings/Options.tsx +0 -34
- package/src/client/settings/authType.ts +0 -18
- package/src/client/settings/schemas/authenticators.ts +0 -402
- package/src/index.ts +0 -1
- package/src/locale/zh-CN.ts +0 -17
- package/src/preset.ts +0 -4
- package/src/server/__tests__/actions.test.ts +0 -142
- package/src/server/__tests__/token-blacklist.test.ts +0 -73
- package/src/server/actions/auth.ts +0 -20
- package/src/server/actions/authenticators.ts +0 -85
- package/src/server/collections/.gitkeep +0 -0
- package/src/server/collections/authenticators.ts +0 -98
- package/src/server/collections/token-blacklist.ts +0 -19
- package/src/server/collections/users-authenticators.ts +0 -73
- package/src/server/index.ts +0 -2
- package/src/server/locale/en-US.ts +0 -10
- package/src/server/locale/fr-FR.ts +0 -10
- package/src/server/locale/index.ts +0 -3
- package/src/server/locale/ja-JP.ts +0 -4
- package/src/server/locale/pt-BR.ts +0 -10
- package/src/server/locale/zh-CN.ts +0 -9
- package/src/server/migrations/20230506152253-basic-authenticator.ts +0 -22
- package/src/server/migrations/20230607174500-update-basic.ts +0 -25
- package/src/server/plugin.ts +0 -92
- package/src/server/token-blacklist.ts +0 -66
- /package/{lib → dist}/client/AuthProvider.d.ts +0 -0
- /package/{lib → dist}/client/basic/Options.d.ts +0 -0
- /package/{lib → dist}/client/basic/SigninPage.d.ts +0 -0
- /package/{lib → dist}/client/basic/SignupPage.d.ts +0 -0
- /package/{lib → dist}/client/index.d.ts +0 -0
- /package/{lib → dist}/client/locale/index.d.ts +0 -0
- /package/{lib → dist}/client/settings/Authenticator.d.ts +0 -0
- /package/{lib → dist}/client/settings/Options.d.ts +0 -0
- /package/{lib → dist}/client/settings/authType.d.ts +0 -0
- /package/{lib → dist}/client/settings/schemas/authenticators.d.ts +0 -0
- /package/{lib → dist}/index.d.ts +0 -0
- /package/{lib → dist}/locale/zh-CN.d.ts +0 -0
- /package/{lib → dist}/server/actions/auth.d.ts +0 -0
- /package/{lib → dist}/server/actions/authenticators.d.ts +0 -0
- /package/{lib → dist}/server/basic-auth.d.ts +0 -0
- /package/{lib → dist}/server/collections/authenticators.d.ts +0 -0
- /package/{lib → dist}/server/collections/token-blacklist.d.ts +0 -0
- /package/{lib → dist}/server/collections/users-authenticators.d.ts +0 -0
- /package/{lib → dist}/server/index.d.ts +0 -0
- /package/{lib → dist}/server/locale/en-US.d.ts +0 -0
- /package/{lib → dist}/server/locale/fr-FR.d.ts +0 -0
- /package/{lib → dist}/server/locale/index.d.ts +0 -0
- /package/{lib → dist}/server/locale/ja-JP.d.ts +0 -0
- /package/{lib → dist}/server/locale/pt-BR.d.ts +0 -0
- /package/{lib → dist}/server/locale/zh-CN.d.ts +0 -0
- /package/{lib → dist}/server/migrations/20230506152253-basic-authenticator.d.ts +0 -0
- /package/{lib → dist}/server/migrations/20230607174500-update-basic.d.ts +0 -0
- /package/{lib → dist}/server/model/authenticator.d.ts +0 -0
- /package/{lib → dist}/server/plugin.d.ts +0 -0
- /package/{lib → dist}/server/token-blacklist.d.ts +0 -0
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
var database = require('@nocobase/database');
|
|
4
|
+
|
|
5
|
+
class AuthModel extends database.Model {
|
|
6
|
+
async findUser(uuid) {
|
|
7
|
+
let user;
|
|
6
8
|
const users = await this.getUsers({
|
|
7
9
|
through: {
|
|
8
|
-
where: { uuid }
|
|
9
|
-
}
|
|
10
|
+
where: { uuid }
|
|
11
|
+
}
|
|
10
12
|
});
|
|
11
13
|
if (users.length) {
|
|
12
14
|
user = users[0];
|
|
13
15
|
return user;
|
|
14
16
|
}
|
|
15
17
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const db: Database = (this.constructor as any).database;
|
|
18
|
+
async newUser(uuid, values) {
|
|
19
|
+
let user;
|
|
20
|
+
const db = this.constructor.database;
|
|
20
21
|
await this.sequelize.transaction(async (transaction) => {
|
|
21
|
-
// Create a new user if not exists
|
|
22
22
|
user = await this.createUser(
|
|
23
23
|
values || {
|
|
24
|
-
nickname: uuid
|
|
24
|
+
nickname: uuid
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
27
|
through: {
|
|
28
|
-
uuid
|
|
28
|
+
uuid
|
|
29
29
|
},
|
|
30
|
-
transaction
|
|
31
|
-
}
|
|
30
|
+
transaction
|
|
31
|
+
}
|
|
32
32
|
);
|
|
33
33
|
await db.emitAsync(`users.afterCreateWithAssociations`, user, {
|
|
34
|
-
transaction
|
|
34
|
+
transaction
|
|
35
35
|
});
|
|
36
36
|
});
|
|
37
37
|
return user;
|
|
38
38
|
}
|
|
39
|
-
|
|
40
|
-
async findOrCreateUser(uuid: string, userValues?: any) {
|
|
39
|
+
async findOrCreateUser(uuid, userValues) {
|
|
41
40
|
const user = await this.findUser(uuid);
|
|
42
41
|
if (user) {
|
|
43
42
|
return user;
|
|
44
43
|
}
|
|
45
|
-
|
|
46
44
|
return await this.newUser(uuid, userValues);
|
|
47
45
|
}
|
|
48
46
|
}
|
|
47
|
+
|
|
48
|
+
exports.AuthModel = AuthModel;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var server = require('@nocobase/server');
|
|
6
|
+
var path = require('path');
|
|
7
|
+
var preset = require('../preset');
|
|
8
|
+
var authActions = require('./actions/auth');
|
|
9
|
+
var authenticatorsActions = require('./actions/authenticators');
|
|
10
|
+
var basicAuth = require('./basic-auth');
|
|
11
|
+
var locale = require('./locale');
|
|
12
|
+
var authenticator = require('./model/authenticator');
|
|
13
|
+
var tokenBlacklist = require('./token-blacklist');
|
|
14
|
+
|
|
15
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
+
|
|
17
|
+
var authActions__default = /*#__PURE__*/_interopDefault(authActions);
|
|
18
|
+
var authenticatorsActions__default = /*#__PURE__*/_interopDefault(authenticatorsActions);
|
|
19
|
+
|
|
20
|
+
class AuthPlugin extends server.Plugin {
|
|
21
|
+
afterAdd() {
|
|
22
|
+
}
|
|
23
|
+
async beforeLoad() {
|
|
24
|
+
this.app.i18n.addResources("zh-CN", preset.namespace, locale.zhCN);
|
|
25
|
+
this.app.i18n.addResources("en-US", preset.namespace, locale.enUS);
|
|
26
|
+
this.app.db.registerModels({ AuthModel: authenticator.AuthModel });
|
|
27
|
+
}
|
|
28
|
+
async load() {
|
|
29
|
+
await this.db.import({
|
|
30
|
+
directory: path.resolve(__dirname, "collections")
|
|
31
|
+
});
|
|
32
|
+
this.db.addMigrations({
|
|
33
|
+
namespace: "auth",
|
|
34
|
+
directory: path.resolve(__dirname, "migrations"),
|
|
35
|
+
context: {
|
|
36
|
+
plugin: this
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
this.app.authManager.setStorer({
|
|
40
|
+
get: async (name) => {
|
|
41
|
+
const repo = this.db.getRepository("authenticators");
|
|
42
|
+
const authenticators = await repo.find({ filter: { enabled: true } });
|
|
43
|
+
const authenticator = authenticators.find((authenticator2) => authenticator2.name === name);
|
|
44
|
+
return authenticator || authenticators[0];
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
if (!this.app.authManager.jwt.blacklist) {
|
|
48
|
+
this.app.authManager.setTokenBlacklistService(new tokenBlacklist.TokenBlacklistService(this));
|
|
49
|
+
}
|
|
50
|
+
this.app.authManager.registerTypes(preset.presetAuthType, {
|
|
51
|
+
auth: basicAuth.BasicAuth
|
|
52
|
+
});
|
|
53
|
+
Object.entries(authActions__default.default).forEach(
|
|
54
|
+
([action, handler]) => this.app.resourcer.registerAction(`auth:${action}`, handler)
|
|
55
|
+
);
|
|
56
|
+
Object.entries(authenticatorsActions__default.default).forEach(
|
|
57
|
+
([action, handler]) => this.app.resourcer.registerAction(`authenticators:${action}`, handler)
|
|
58
|
+
);
|
|
59
|
+
["check", "signIn", "signUp"].forEach((action) => this.app.acl.allow("auth", action));
|
|
60
|
+
["signOut", "changePassword"].forEach((action) => this.app.acl.allow("auth", action, "loggedIn"));
|
|
61
|
+
this.app.acl.allow("authenticators", "publicList");
|
|
62
|
+
this.app.acl.registerSnippet({
|
|
63
|
+
name: `pm.${this.name}.authenticators`,
|
|
64
|
+
actions: ["authenticators:*"]
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
async install(options) {
|
|
68
|
+
const repository = this.db.getRepository("authenticators");
|
|
69
|
+
const exist = await repository.findOne({ filter: { name: preset.presetAuthenticator } });
|
|
70
|
+
if (exist) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
await repository.create({
|
|
74
|
+
values: {
|
|
75
|
+
name: preset.presetAuthenticator,
|
|
76
|
+
authType: preset.presetAuthType,
|
|
77
|
+
description: "Sign in with email and password.",
|
|
78
|
+
enabled: true,
|
|
79
|
+
options: {
|
|
80
|
+
public: {
|
|
81
|
+
allowSignUp: true
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
async remove() {
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
var plugin_default = AuthPlugin;
|
|
91
|
+
|
|
92
|
+
exports.AuthPlugin = AuthPlugin;
|
|
93
|
+
exports.default = plugin_default;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var cron = require('cron');
|
|
4
|
+
|
|
5
|
+
class TokenBlacklistService {
|
|
6
|
+
constructor(plugin) {
|
|
7
|
+
this.plugin = plugin;
|
|
8
|
+
this.repo = plugin.db.getRepository("tokenBlacklist");
|
|
9
|
+
this.cronJob = this.createCronJob();
|
|
10
|
+
}
|
|
11
|
+
repo;
|
|
12
|
+
cronJob;
|
|
13
|
+
get app() {
|
|
14
|
+
return this.plugin.app;
|
|
15
|
+
}
|
|
16
|
+
createCronJob() {
|
|
17
|
+
const cronJob = new cron.CronJob(
|
|
18
|
+
// every day at 03:00
|
|
19
|
+
"0 3 * * *",
|
|
20
|
+
//
|
|
21
|
+
async () => {
|
|
22
|
+
this.app.logger.info(`${this.plugin.name}: Start delete expired blacklist token`);
|
|
23
|
+
await this.deleteByExpiration();
|
|
24
|
+
this.app.logger.info(`${this.plugin.name}: End delete expired blacklist token`);
|
|
25
|
+
},
|
|
26
|
+
null
|
|
27
|
+
);
|
|
28
|
+
this.app.once("beforeStart", () => {
|
|
29
|
+
cronJob.start();
|
|
30
|
+
});
|
|
31
|
+
this.app.once("beforeStop", () => {
|
|
32
|
+
cronJob.stop();
|
|
33
|
+
});
|
|
34
|
+
return cronJob;
|
|
35
|
+
}
|
|
36
|
+
async has(token) {
|
|
37
|
+
return !!await this.repo.findOne({
|
|
38
|
+
filter: {
|
|
39
|
+
token
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
async add(values) {
|
|
44
|
+
return this.repo.model.findOrCreate({
|
|
45
|
+
defaults: values,
|
|
46
|
+
where: {
|
|
47
|
+
token: values.token
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
async deleteByExpiration() {
|
|
52
|
+
return this.repo.destroy({
|
|
53
|
+
filter: {
|
|
54
|
+
expiration: {
|
|
55
|
+
$dateNotAfter: /* @__PURE__ */ new Date()
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
exports.TokenBlacklistService = TokenBlacklistService;
|
package/package.json
CHANGED
|
@@ -1,39 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-auth",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"main": "./
|
|
5
|
-
"files": [
|
|
6
|
-
"lib",
|
|
7
|
-
"src",
|
|
8
|
-
"README.md",
|
|
9
|
-
"README.zh-CN.md",
|
|
10
|
-
"CHANGELOG.md",
|
|
11
|
-
"server.js",
|
|
12
|
-
"server.d.ts",
|
|
13
|
-
"client.js",
|
|
14
|
-
"client.d.ts"
|
|
15
|
-
],
|
|
3
|
+
"version": "0.12.0-alpha.1",
|
|
4
|
+
"main": "./dist/server/index.js",
|
|
16
5
|
"devDependencies": {
|
|
17
|
-
"@ant-design/icons": "
|
|
18
|
-
"@formily/react": "2.
|
|
19
|
-
"@formily/shared": "2.
|
|
20
|
-
"@nocobase/auth": "0.11.1-alpha.4",
|
|
21
|
-
"@nocobase/test": "0.11.1-alpha.4",
|
|
6
|
+
"@ant-design/icons": "5.x",
|
|
7
|
+
"@formily/react": "2.x",
|
|
8
|
+
"@formily/shared": "2.x",
|
|
22
9
|
"@types/cron": "^2.0.1",
|
|
23
|
-
"antd": "
|
|
10
|
+
"antd": "5.x",
|
|
11
|
+
"cron": "^2.3.1",
|
|
24
12
|
"react": "^18.2.0",
|
|
25
13
|
"react-i18next": "^11.15.1"
|
|
26
14
|
},
|
|
27
|
-
"
|
|
28
|
-
"@nocobase/actions": "0.
|
|
29
|
-
"@nocobase/
|
|
30
|
-
"@nocobase/
|
|
31
|
-
"@nocobase/
|
|
32
|
-
"
|
|
15
|
+
"peerDependencies": {
|
|
16
|
+
"@nocobase/actions": "0.x",
|
|
17
|
+
"@nocobase/auth": "0.x",
|
|
18
|
+
"@nocobase/client": "0.x",
|
|
19
|
+
"@nocobase/database": "0.x",
|
|
20
|
+
"@nocobase/server": "0.x",
|
|
21
|
+
"@nocobase/test": "0.x"
|
|
33
22
|
},
|
|
34
23
|
"displayName": "Authentication",
|
|
35
24
|
"displayName.zh-CN": "用户认证",
|
|
36
|
-
"description": "Basic authentication and authenticator management
|
|
37
|
-
"description.zh-CN": "
|
|
38
|
-
"gitHead": "
|
|
25
|
+
"description": "Basic authentication and authenticator management",
|
|
26
|
+
"description.zh-CN": "提供基础认证功能和扩展认证器管理功能",
|
|
27
|
+
"gitHead": "543dcc0216b7b1451b552b0f685bc3e0682f9d59"
|
|
39
28
|
}
|
package/server.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export { default } from './
|
|
1
|
+
export * from './dist/server';
|
|
2
|
+
export { default } from './dist/server';
|
package/server.js
CHANGED
|
@@ -39,7 +39,7 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
39
39
|
return newObj;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
var _index = _interopRequireWildcard(require('./
|
|
42
|
+
var _index = _interopRequireWildcard(require('./dist/server'));
|
|
43
43
|
|
|
44
44
|
Object.defineProperty(exports, '__esModule', {
|
|
45
45
|
value: true,
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.AuthProvider = 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
|
-
const AuthProvider = 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.AuthProvider = AuthProvider;
|
|
@@ -1,51 +0,0 @@
|
|
|
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;
|
|
@@ -1,100 +0,0 @@
|
|
|
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;
|
|
@@ -1,131 +0,0 @@
|
|
|
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;
|
package/lib/client/index.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = exports.AuthPlugin = void 0;
|
|
7
|
-
function _client() {
|
|
8
|
-
const data = require("@nocobase/client");
|
|
9
|
-
_client = function _client() {
|
|
10
|
-
return data;
|
|
11
|
-
};
|
|
12
|
-
return data;
|
|
13
|
-
}
|
|
14
|
-
var _AuthProvider = require("./AuthProvider");
|
|
15
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
16
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
17
|
-
class AuthPlugin extends _client().Plugin {
|
|
18
|
-
load() {
|
|
19
|
-
var _this = this;
|
|
20
|
-
return _asyncToGenerator(function* () {
|
|
21
|
-
_this.app.use(_AuthProvider.AuthProvider);
|
|
22
|
-
})();
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
exports.AuthPlugin = AuthPlugin;
|
|
26
|
-
var _default = AuthPlugin;
|
|
27
|
-
exports.default = _default;
|
|
@@ -1,19 +0,0 @@
|
|
|
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
|
-
}
|