@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
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.BasicAuth = void 0;
|
|
7
|
+
function _auth() {
|
|
8
|
+
const data = require("@nocobase/auth");
|
|
9
|
+
_auth = function _auth() {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
var _preset = require("../preset");
|
|
15
|
+
function _crypto() {
|
|
16
|
+
const data = _interopRequireDefault(require("crypto"));
|
|
17
|
+
_crypto = function _crypto() {
|
|
18
|
+
return data;
|
|
19
|
+
};
|
|
20
|
+
return data;
|
|
21
|
+
}
|
|
22
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
+
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); } }
|
|
24
|
+
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); }); }; }
|
|
25
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
26
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
27
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
28
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
29
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
30
|
+
class BasicAuth extends _auth().BaseAuth {
|
|
31
|
+
constructor(config) {
|
|
32
|
+
const userCollection = config.ctx.db.getCollection('users');
|
|
33
|
+
super(_objectSpread(_objectSpread({}, config), {}, {
|
|
34
|
+
userCollection
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
validate() {
|
|
38
|
+
var _this = this;
|
|
39
|
+
return _asyncToGenerator(function* () {
|
|
40
|
+
const ctx = _this.ctx;
|
|
41
|
+
const _ctx$action$params = ctx.action.params,
|
|
42
|
+
_ctx$action$params$un = _ctx$action$params.uniqueField,
|
|
43
|
+
uniqueField = _ctx$action$params$un === void 0 ? 'email' : _ctx$action$params$un,
|
|
44
|
+
values = _ctx$action$params.values;
|
|
45
|
+
if (!values[uniqueField]) {
|
|
46
|
+
ctx.throw(400, ctx.t('Please fill in your email address', {
|
|
47
|
+
ns: _preset.namespace
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
const user = yield _this.userCollection.repository.findOne({
|
|
51
|
+
where: {
|
|
52
|
+
[uniqueField]: values[uniqueField]
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
if (!user) {
|
|
56
|
+
ctx.throw(401, ctx.t('The email is incorrect, please re-enter', {
|
|
57
|
+
ns: _preset.namespace
|
|
58
|
+
}));
|
|
59
|
+
}
|
|
60
|
+
const field = _this.userCollection.getField('password');
|
|
61
|
+
const valid = yield field.verify(values.password, user.password);
|
|
62
|
+
if (!valid) {
|
|
63
|
+
ctx.throw(401, ctx.t('The password is incorrect, please re-enter', {
|
|
64
|
+
ns: _preset.namespace
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
return user;
|
|
68
|
+
})();
|
|
69
|
+
}
|
|
70
|
+
signUp() {
|
|
71
|
+
var _this2 = this;
|
|
72
|
+
return _asyncToGenerator(function* () {
|
|
73
|
+
var _this2$authenticator$;
|
|
74
|
+
const ctx = _this2.ctx;
|
|
75
|
+
const options = ((_this2$authenticator$ = _this2.authenticator.options) === null || _this2$authenticator$ === void 0 ? void 0 : _this2$authenticator$.public) || {};
|
|
76
|
+
if (!options.allowSignUp) {
|
|
77
|
+
ctx.throw(403, ctx.t('Not allowed to sign up', {
|
|
78
|
+
ns: _preset.namespace
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
81
|
+
const User = ctx.db.getRepository('users');
|
|
82
|
+
const values = ctx.action.params.values;
|
|
83
|
+
const user = yield User.create({
|
|
84
|
+
values
|
|
85
|
+
});
|
|
86
|
+
return user;
|
|
87
|
+
})();
|
|
88
|
+
}
|
|
89
|
+
lostPassword() {
|
|
90
|
+
var _this3 = this;
|
|
91
|
+
return _asyncToGenerator(function* () {
|
|
92
|
+
const ctx = _this3.ctx;
|
|
93
|
+
const email = ctx.action.params.values.email;
|
|
94
|
+
if (!email) {
|
|
95
|
+
ctx.throw(400, ctx.t('Please fill in your email address', {
|
|
96
|
+
ns: _preset.namespace
|
|
97
|
+
}));
|
|
98
|
+
}
|
|
99
|
+
const user = yield _this3.userCollection.repository.findOne({
|
|
100
|
+
where: {
|
|
101
|
+
email
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
if (!user) {
|
|
105
|
+
ctx.throw(401, ctx.t('The email is incorrect, please re-enter', {
|
|
106
|
+
ns: _preset.namespace
|
|
107
|
+
}));
|
|
108
|
+
}
|
|
109
|
+
user.resetToken = _crypto().default.randomBytes(20).toString('hex');
|
|
110
|
+
yield user.save();
|
|
111
|
+
return user;
|
|
112
|
+
})();
|
|
113
|
+
}
|
|
114
|
+
resetPassword() {
|
|
115
|
+
var _this4 = this;
|
|
116
|
+
return _asyncToGenerator(function* () {
|
|
117
|
+
const ctx = _this4.ctx;
|
|
118
|
+
const _ctx$action$params$va = ctx.action.params.values,
|
|
119
|
+
email = _ctx$action$params$va.email,
|
|
120
|
+
password = _ctx$action$params$va.password,
|
|
121
|
+
resetToken = _ctx$action$params$va.resetToken;
|
|
122
|
+
const user = yield _this4.userCollection.repository.findOne({
|
|
123
|
+
where: {
|
|
124
|
+
email,
|
|
125
|
+
resetToken
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
if (!user) {
|
|
129
|
+
ctx.throw(404);
|
|
130
|
+
}
|
|
131
|
+
user.token = null;
|
|
132
|
+
user.resetToken = null;
|
|
133
|
+
user.password = password;
|
|
134
|
+
yield user.save();
|
|
135
|
+
return user;
|
|
136
|
+
})();
|
|
137
|
+
}
|
|
138
|
+
getUserByResetToken() {
|
|
139
|
+
var _this5 = this;
|
|
140
|
+
return _asyncToGenerator(function* () {
|
|
141
|
+
const ctx = _this5.ctx;
|
|
142
|
+
const token = ctx.action.params.token;
|
|
143
|
+
const user = yield _this5.userCollection.repository.findOne({
|
|
144
|
+
where: {
|
|
145
|
+
resetToken: token
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
if (!user) {
|
|
149
|
+
ctx.throw(401);
|
|
150
|
+
}
|
|
151
|
+
return user;
|
|
152
|
+
})();
|
|
153
|
+
}
|
|
154
|
+
changePassword() {
|
|
155
|
+
var _this6 = this;
|
|
156
|
+
return _asyncToGenerator(function* () {
|
|
157
|
+
const ctx = _this6.ctx;
|
|
158
|
+
const _ctx$action$params$va2 = ctx.action.params.values,
|
|
159
|
+
oldPassword = _ctx$action$params$va2.oldPassword,
|
|
160
|
+
newPassword = _ctx$action$params$va2.newPassword;
|
|
161
|
+
const currentUser = ctx.auth.user;
|
|
162
|
+
if (!currentUser) {
|
|
163
|
+
ctx.throw(401);
|
|
164
|
+
}
|
|
165
|
+
const user = yield _this6.userCollection.repository.findOne({
|
|
166
|
+
where: {
|
|
167
|
+
email: currentUser.email
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
const pwd = _this6.userCollection.getField('password');
|
|
171
|
+
const isValid = yield pwd.verify(oldPassword, user.password);
|
|
172
|
+
if (!isValid) {
|
|
173
|
+
ctx.throw(401, ctx.t('The password is incorrect, please re-enter', {
|
|
174
|
+
ns: _preset.namespace
|
|
175
|
+
}));
|
|
176
|
+
}
|
|
177
|
+
user.password = newPassword;
|
|
178
|
+
yield user.save();
|
|
179
|
+
return currentUser;
|
|
180
|
+
})();
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
exports.BasicAuth = BasicAuth;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Collection for extended authentication methods,
|
|
9
|
+
*/
|
|
10
|
+
var _default = {
|
|
11
|
+
namespace: 'auth.auth',
|
|
12
|
+
duplicator: 'optional',
|
|
13
|
+
name: 'authenticators',
|
|
14
|
+
sortable: true,
|
|
15
|
+
title: '{{t("Authenticators")}}',
|
|
16
|
+
model: 'AuthModel',
|
|
17
|
+
createdBy: true,
|
|
18
|
+
updatedBy: true,
|
|
19
|
+
logging: true,
|
|
20
|
+
fields: [{
|
|
21
|
+
name: 'id',
|
|
22
|
+
type: 'bigInt',
|
|
23
|
+
autoIncrement: true,
|
|
24
|
+
primaryKey: true,
|
|
25
|
+
allowNull: false,
|
|
26
|
+
interface: 'id'
|
|
27
|
+
}, {
|
|
28
|
+
interface: 'input',
|
|
29
|
+
type: 'string',
|
|
30
|
+
name: 'name',
|
|
31
|
+
allowNull: false,
|
|
32
|
+
unique: true,
|
|
33
|
+
uiSchema: {
|
|
34
|
+
type: 'string',
|
|
35
|
+
title: '{{t("Name")}}',
|
|
36
|
+
'x-component': 'Input',
|
|
37
|
+
required: true
|
|
38
|
+
}
|
|
39
|
+
}, {
|
|
40
|
+
interface: 'input',
|
|
41
|
+
type: 'string',
|
|
42
|
+
name: 'authType',
|
|
43
|
+
allowNull: false,
|
|
44
|
+
uiSchema: {
|
|
45
|
+
type: 'string',
|
|
46
|
+
title: '{{t("Auth Type")}}',
|
|
47
|
+
'x-component': 'Input',
|
|
48
|
+
required: true
|
|
49
|
+
}
|
|
50
|
+
}, {
|
|
51
|
+
interface: 'input',
|
|
52
|
+
type: 'string',
|
|
53
|
+
name: 'title',
|
|
54
|
+
uiSchema: {
|
|
55
|
+
type: 'string',
|
|
56
|
+
title: '{{t("Title")}}',
|
|
57
|
+
'x-component': 'Input'
|
|
58
|
+
}
|
|
59
|
+
}, {
|
|
60
|
+
interface: 'textarea',
|
|
61
|
+
type: 'string',
|
|
62
|
+
name: 'description',
|
|
63
|
+
allowNull: false,
|
|
64
|
+
defaultValue: '',
|
|
65
|
+
uiSchema: {
|
|
66
|
+
type: 'string',
|
|
67
|
+
title: '{{t("Description")}}',
|
|
68
|
+
'x-component': 'Input',
|
|
69
|
+
required: true
|
|
70
|
+
}
|
|
71
|
+
}, {
|
|
72
|
+
type: 'json',
|
|
73
|
+
name: 'options',
|
|
74
|
+
allowNull: false,
|
|
75
|
+
defaultValue: {}
|
|
76
|
+
}, {
|
|
77
|
+
type: 'boolean',
|
|
78
|
+
name: 'enabled',
|
|
79
|
+
defaultValue: false
|
|
80
|
+
}, {
|
|
81
|
+
interface: 'm2m',
|
|
82
|
+
type: 'belongsToMany',
|
|
83
|
+
name: 'users',
|
|
84
|
+
target: 'users',
|
|
85
|
+
foreignKey: 'authenticator',
|
|
86
|
+
otherKey: 'userId',
|
|
87
|
+
onDelete: 'CASCADE',
|
|
88
|
+
sourceKey: 'name',
|
|
89
|
+
targetKey: 'id',
|
|
90
|
+
through: 'usersAuthenticators'
|
|
91
|
+
}]
|
|
92
|
+
};
|
|
93
|
+
exports.default = _default;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Collection for user information of extended authentication methods,
|
|
9
|
+
* such as saml, oicd, oauth, sms, etc.
|
|
10
|
+
*/
|
|
11
|
+
var _default = {
|
|
12
|
+
namespace: 'auth.auth',
|
|
13
|
+
duplicator: {
|
|
14
|
+
dumpable: 'optional',
|
|
15
|
+
/**
|
|
16
|
+
* When dump this collection, the users collection is required to be dumped.
|
|
17
|
+
*/
|
|
18
|
+
with: 'users'
|
|
19
|
+
},
|
|
20
|
+
name: 'usersAuthenticators',
|
|
21
|
+
title: '{{t("Users Authenticators")}}',
|
|
22
|
+
model: 'UserAuthModel',
|
|
23
|
+
createdBy: true,
|
|
24
|
+
updatedBy: true,
|
|
25
|
+
logging: true,
|
|
26
|
+
fields: [
|
|
27
|
+
/**
|
|
28
|
+
* uuid:
|
|
29
|
+
* Unique user id of the authentication method, such as wechat openid, phone number, etc.
|
|
30
|
+
*/
|
|
31
|
+
{
|
|
32
|
+
name: 'uuid',
|
|
33
|
+
interface: 'input',
|
|
34
|
+
type: 'string',
|
|
35
|
+
allowNull: false,
|
|
36
|
+
uiSchema: {
|
|
37
|
+
type: 'string',
|
|
38
|
+
title: '{{t("UUID")}}',
|
|
39
|
+
'x-component': 'Input',
|
|
40
|
+
required: true
|
|
41
|
+
}
|
|
42
|
+
}, {
|
|
43
|
+
interface: 'input',
|
|
44
|
+
type: 'string',
|
|
45
|
+
name: 'nickname',
|
|
46
|
+
allowNull: false,
|
|
47
|
+
defaultValue: '',
|
|
48
|
+
uiSchema: {
|
|
49
|
+
type: 'string',
|
|
50
|
+
title: '{{t("Nickname")}}',
|
|
51
|
+
'x-component': 'Input'
|
|
52
|
+
}
|
|
53
|
+
}, {
|
|
54
|
+
interface: 'attachment',
|
|
55
|
+
type: 'string',
|
|
56
|
+
name: 'avatar',
|
|
57
|
+
allowNull: false,
|
|
58
|
+
defaultValue: '',
|
|
59
|
+
uiSchema: {
|
|
60
|
+
type: 'string',
|
|
61
|
+
title: '{{t("Avatar")}}',
|
|
62
|
+
'x-component': 'Upload'
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
/**
|
|
66
|
+
* meta:
|
|
67
|
+
* Metadata, some other information of the authentication method.
|
|
68
|
+
*/
|
|
69
|
+
{
|
|
70
|
+
type: 'json',
|
|
71
|
+
name: 'meta',
|
|
72
|
+
defaultValue: {}
|
|
73
|
+
}]
|
|
74
|
+
};
|
|
75
|
+
exports.default = _default;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "AuthModel", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _authenticator.AuthModel;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "default", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _plugin.default;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var _plugin = _interopRequireDefault(require("./plugin"));
|
|
19
|
+
var _authenticator = require("./model/authenticator");
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
'The email is incorrect, please re-enter': string;
|
|
3
|
+
'Please fill in your email address': string;
|
|
4
|
+
'The password is incorrect, please re-enter': string;
|
|
5
|
+
'Not a valid cellphone number, please re-enter': string;
|
|
6
|
+
'The phone number has been registered, please login directly': string;
|
|
7
|
+
'The phone number is not registered, please register first': string;
|
|
8
|
+
};
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = {
|
|
8
|
+
'The email is incorrect, please re-enter': 'The email is incorrect, please re-enter',
|
|
9
|
+
'Please fill in your email address': 'Please fill in your email address',
|
|
10
|
+
'The password is incorrect, please re-enter': 'The password is incorrect, please re-enter',
|
|
11
|
+
'Not a valid cellphone number, please re-enter': 'Not a valid cellphone number, please re-enter',
|
|
12
|
+
'The phone number has been registered, please login directly': 'The phone number has been registered, please login directly',
|
|
13
|
+
'The phone number is not registered, please register first': 'The phone number is not registered, please register first'
|
|
14
|
+
};
|
|
15
|
+
exports.default = _default;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "enUS", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _enUS.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "ptBR", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _ptBR.default;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "zhCN", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _zhCN.default;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
var _enUS = _interopRequireDefault(require("./en-US"));
|
|
25
|
+
var _zhCN = _interopRequireDefault(require("./zh-CN"));
|
|
26
|
+
var _ptBR = _interopRequireDefault(require("./pt-BR"));
|
|
27
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = {
|
|
8
|
+
'Please fill in your email address': 'メールアドレスを入力してください',
|
|
9
|
+
'The password is incorrect, please re-enter': 'パスワードが正しくありません。再度入力してください。'
|
|
10
|
+
};
|
|
11
|
+
exports.default = _default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
'The email is incorrect, please re-enter': string;
|
|
3
|
+
'Please fill in your email address': string;
|
|
4
|
+
'The password is incorrect, please re-enter': string;
|
|
5
|
+
'Not a valid cellphone number, please re-enter': string;
|
|
6
|
+
'The phone number has been registered, please login directly': string;
|
|
7
|
+
'The phone number is not registered, please register first': string;
|
|
8
|
+
};
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = {
|
|
8
|
+
'The email is incorrect, please re-enter': 'O e-mail está incorreto, por favor, digite novamente',
|
|
9
|
+
'Please fill in your email address': 'Por favor, preencha o seu endereço de e-mail',
|
|
10
|
+
'The password is incorrect, please re-enter': 'A senha está incorreta, por favor, digite novamente',
|
|
11
|
+
'Not a valid cellphone number, please re-enter': 'Número de celular inválido, por favor, digite novamente',
|
|
12
|
+
'The phone number has been registered, please login directly': 'O número de celular já está registrado, por favor, faça login diretamente',
|
|
13
|
+
'The phone number is not registered, please register first': 'O número de celular não está registrado, por favor, registre-se primeiro'
|
|
14
|
+
};
|
|
15
|
+
exports.default = _default;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
'The email is incorrect, please re-enter': string;
|
|
3
|
+
'Please fill in your email address': string;
|
|
4
|
+
'The password is incorrect, please re-enter': string;
|
|
5
|
+
'Not a valid cellphone number, please re-enter': string;
|
|
6
|
+
'The phone number has been registered, please login directly': string;
|
|
7
|
+
'The phone number is not registered, please register first': string;
|
|
8
|
+
'Please keep and enable at least one authenticator': string;
|
|
9
|
+
};
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = {
|
|
8
|
+
'The email is incorrect, please re-enter': '邮箱有误,请重新输入',
|
|
9
|
+
'Please fill in your email address': '请填写邮箱',
|
|
10
|
+
'The password is incorrect, please re-enter': '密码有误,请重新输入',
|
|
11
|
+
'Not a valid cellphone number, please re-enter': '不是有效的手机号,请重新输入',
|
|
12
|
+
'The phone number has been registered, please login directly': '手机号已注册,请直接登录',
|
|
13
|
+
'The phone number is not registered, please register first': '手机号未注册,请先注册',
|
|
14
|
+
'Please keep and enable at least one authenticator': '请至少保留并启用一个认证器'
|
|
15
|
+
};
|
|
16
|
+
exports.default = _default;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
function _server() {
|
|
8
|
+
const data = require("@nocobase/server");
|
|
9
|
+
_server = function _server() {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
var _preset = require("../../preset");
|
|
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 AddBasicAuthMigration extends _server().Migration {
|
|
18
|
+
up() {
|
|
19
|
+
var _this = this;
|
|
20
|
+
return _asyncToGenerator(function* () {
|
|
21
|
+
const repo = _this.context.db.getRepository('authenticators');
|
|
22
|
+
const existed = yield repo.count();
|
|
23
|
+
if (existed) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
yield repo.create({
|
|
27
|
+
values: {
|
|
28
|
+
name: _preset.presetAuthenticator,
|
|
29
|
+
authType: _preset.presetAuthType,
|
|
30
|
+
description: 'Sign in with email and password.',
|
|
31
|
+
enabled: true
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
})();
|
|
35
|
+
}
|
|
36
|
+
down() {
|
|
37
|
+
return _asyncToGenerator(function* () {})();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.default = AddBasicAuthMigration;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
function _server() {
|
|
8
|
+
const data = require("@nocobase/server");
|
|
9
|
+
_server = function _server() {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
var _preset = require("../../preset");
|
|
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 UpdateBasicAuthMigration extends _server().Migration {
|
|
18
|
+
up() {
|
|
19
|
+
var _this = this;
|
|
20
|
+
return _asyncToGenerator(function* () {
|
|
21
|
+
const SystemSetting = _this.context.db.getRepository('systemSettings');
|
|
22
|
+
const setting = yield SystemSetting.findOne();
|
|
23
|
+
const allowSignUp = setting.get('allowSignUp') ? true : false;
|
|
24
|
+
const repo = _this.context.db.getRepository('authenticators');
|
|
25
|
+
yield repo.update({
|
|
26
|
+
values: {
|
|
27
|
+
options: {
|
|
28
|
+
public: {
|
|
29
|
+
allowSignUp
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
filter: {
|
|
34
|
+
name: _preset.presetAuthenticator
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
})();
|
|
38
|
+
}
|
|
39
|
+
down() {
|
|
40
|
+
return _asyncToGenerator(function* () {})();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.default = UpdateBasicAuthMigration;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Model } from '@nocobase/database';
|
|
2
|
+
export declare class AuthModel extends Model {
|
|
3
|
+
findUser(uuid: string): Promise<Model<any, any>>;
|
|
4
|
+
newUser(uuid: string, values?: any): Promise<Model<any, any>>;
|
|
5
|
+
findOrCreateUser(uuid: string, userValues?: any): Promise<Model<any, any>>;
|
|
6
|
+
}
|