@nocobase/plugin-users 0.7.0-alpha.8 → 0.7.0-alpha.82
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/lib/actions/users.js +279 -163
- package/lib/collections/roles-users.js +12 -5
- package/lib/collections/users.js +87 -86
- package/lib/index.d.ts +1 -0
- package/lib/index.js +19 -8
- package/lib/jwt-service.js +50 -29
- package/lib/locale/en-US.d.ts +5 -0
- package/lib/locale/en-US.js +11 -0
- package/lib/locale/index.d.ts +2 -0
- package/lib/locale/index.js +23 -0
- package/lib/locale/zh-CN.d.ts +6 -0
- package/lib/locale/zh-CN.js +12 -0
- package/lib/middlewares/check.js +28 -23
- package/lib/middlewares/index.js +20 -7
- package/lib/middlewares/parseToken.js +86 -62
- package/lib/models/UserModel.d.ts +2 -2
- package/lib/models/UserModel.js +68 -53
- package/lib/server.d.ts +5 -10
- package/lib/server.js +261 -149
- package/package.json +3 -8
- package/esm/actions/users.d.ts +0 -11
- package/esm/actions/users.js +0 -165
- package/esm/actions/users.js.map +0 -1
- package/esm/collections/roles-users.d.ts +0 -3
- package/esm/collections/roles-users.js +0 -5
- package/esm/collections/roles-users.js.map +0 -1
- package/esm/collections/users.d.ts +0 -3
- package/esm/collections/users.js +0 -86
- package/esm/collections/users.js.map +0 -1
- package/esm/index.d.ts +0 -1
- package/esm/index.js +0 -2
- package/esm/index.js.map +0 -1
- package/esm/jwt-service.d.ts +0 -12
- package/esm/jwt-service.js +0 -26
- package/esm/jwt-service.js.map +0 -1
- package/esm/middlewares/check.d.ts +0 -1
- package/esm/middlewares/check.js +0 -22
- package/esm/middlewares/check.js.map +0 -1
- package/esm/middlewares/index.d.ts +0 -2
- package/esm/middlewares/index.js +0 -3
- package/esm/middlewares/index.js.map +0 -1
- package/esm/middlewares/parseToken.d.ts +0 -6
- package/esm/middlewares/parseToken.js +0 -64
- package/esm/middlewares/parseToken.js.map +0 -1
- package/esm/models/UserModel.d.ts +0 -4
- package/esm/models/UserModel.js +0 -53
- package/esm/models/UserModel.js.map +0 -1
- package/esm/server.d.ts +0 -23
- package/esm/server.js +0 -133
- package/esm/server.js.map +0 -1
- package/lib/actions/users.js.map +0 -1
- package/lib/collections/roles-users.js.map +0 -1
- package/lib/collections/users.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/jwt-service.js.map +0 -1
- package/lib/middlewares/check.js.map +0 -1
- package/lib/middlewares/index.js.map +0 -1
- package/lib/middlewares/parseToken.js.map +0 -1
- package/lib/models/UserModel.js.map +0 -1
- package/lib/server.js.map +0 -1
- package/tsconfig.build.json +0 -9
package/lib/actions/users.js
CHANGED
|
@@ -1,181 +1,297 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.changePassword = changePassword;
|
|
7
|
+
exports.check = check;
|
|
8
|
+
exports.getUserByResetToken = getUserByResetToken;
|
|
9
|
+
exports.lostpassword = lostpassword;
|
|
10
|
+
exports.resetpassword = resetpassword;
|
|
11
|
+
exports.setDefaultRole = setDefaultRole;
|
|
12
|
+
exports.signin = signin;
|
|
13
|
+
exports.signout = signout;
|
|
14
|
+
exports.signup = signup;
|
|
15
|
+
exports.updateProfile = updateProfile;
|
|
16
|
+
|
|
17
|
+
function _crypto() {
|
|
18
|
+
const data = _interopRequireDefault(require("crypto"));
|
|
19
|
+
|
|
20
|
+
_crypto = function _crypto() {
|
|
21
|
+
return data;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
return data;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
var _ = require("../");
|
|
28
|
+
|
|
29
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
30
|
+
|
|
31
|
+
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; }
|
|
32
|
+
|
|
33
|
+
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; }
|
|
34
|
+
|
|
35
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
36
|
+
|
|
37
|
+
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); } }
|
|
38
|
+
|
|
39
|
+
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); }); }; }
|
|
40
|
+
|
|
41
|
+
function check(_x, _x2) {
|
|
42
|
+
return _check.apply(this, arguments);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function _check() {
|
|
46
|
+
_check = _asyncToGenerator(function* (ctx, next) {
|
|
47
|
+
if (ctx.state.currentUser) {
|
|
48
|
+
const user = ctx.state.currentUser.toJSON();
|
|
49
|
+
ctx.body = user;
|
|
50
|
+
} else {
|
|
51
|
+
ctx.body = {};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
yield next();
|
|
55
|
+
});
|
|
56
|
+
return _check.apply(this, arguments);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function signin(_x3, _x4) {
|
|
60
|
+
return _signin.apply(this, arguments);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function _signin() {
|
|
64
|
+
_signin = _asyncToGenerator(function* (ctx, next) {
|
|
65
|
+
const _ctx$action$params = ctx.action.params,
|
|
66
|
+
_ctx$action$params$un = _ctx$action$params.uniqueField,
|
|
67
|
+
uniqueField = _ctx$action$params$un === void 0 ? 'email' : _ctx$action$params$un,
|
|
68
|
+
values = _ctx$action$params.values;
|
|
69
|
+
|
|
70
|
+
if (!values[uniqueField]) {
|
|
71
|
+
ctx.throw(401, ctx.t('Please fill in your email address', {
|
|
72
|
+
ns: _.namespace
|
|
73
|
+
}));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const User = ctx.db.getCollection('users');
|
|
77
|
+
const user = yield User.model.findOne({
|
|
78
|
+
where: {
|
|
79
|
+
[uniqueField]: values[uniqueField]
|
|
80
|
+
}
|
|
9
81
|
});
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
82
|
+
|
|
83
|
+
if (!user) {
|
|
84
|
+
ctx.throw(401, ctx.t('The email is incorrect, please re-enter', {
|
|
85
|
+
ns: _.namespace
|
|
86
|
+
}));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const pwd = User.getField('password');
|
|
90
|
+
const isValid = yield pwd.verify(values.password, user.password);
|
|
91
|
+
|
|
92
|
+
if (!isValid) {
|
|
93
|
+
ctx.throw(401, ctx.t('The password is incorrect, please re-enter', {
|
|
94
|
+
ns: _.namespace
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const pluginUser = ctx.app.getPlugin('@nocobase/plugin-users');
|
|
99
|
+
ctx.body = _objectSpread(_objectSpread({}, user.toJSON()), {}, {
|
|
100
|
+
token: pluginUser.jwtService.sign({
|
|
101
|
+
userId: user.get('id')
|
|
102
|
+
})
|
|
27
103
|
});
|
|
104
|
+
yield next();
|
|
105
|
+
});
|
|
106
|
+
return _signin.apply(this, arguments);
|
|
28
107
|
}
|
|
29
|
-
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
const { uniqueField = 'email', values } = ctx.action.params;
|
|
33
|
-
if (!values[uniqueField]) {
|
|
34
|
-
ctx.throw(401, '请填写邮箱账号');
|
|
35
|
-
}
|
|
36
|
-
const User = ctx.db.getCollection('users');
|
|
37
|
-
const user = yield User.model.findOne({
|
|
38
|
-
where: {
|
|
39
|
-
[uniqueField]: values[uniqueField],
|
|
40
|
-
},
|
|
41
|
-
});
|
|
42
|
-
if (!user) {
|
|
43
|
-
ctx.throw(401, '邮箱账号未注册');
|
|
44
|
-
}
|
|
45
|
-
const pwd = User.getField('password');
|
|
46
|
-
const isValid = yield pwd.verify(values.password, user.password);
|
|
47
|
-
if (!isValid) {
|
|
48
|
-
ctx.throw(401, '密码错误,请您重新输入');
|
|
49
|
-
}
|
|
50
|
-
const pluginUser = ctx.app.getPlugin('@nocobase/plugin-users');
|
|
51
|
-
ctx.body = Object.assign(Object.assign({}, user.toJSON()), { token: pluginUser.jwtService.sign({
|
|
52
|
-
userId: user.get('id'),
|
|
53
|
-
}) });
|
|
54
|
-
yield next();
|
|
55
|
-
});
|
|
108
|
+
|
|
109
|
+
function signout(_x5, _x6) {
|
|
110
|
+
return _signout.apply(this, arguments);
|
|
56
111
|
}
|
|
57
|
-
|
|
58
|
-
function
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
112
|
+
|
|
113
|
+
function _signout() {
|
|
114
|
+
_signout = _asyncToGenerator(function* (ctx, next) {
|
|
115
|
+
ctx.body = ctx.state.currentUser;
|
|
116
|
+
yield next();
|
|
117
|
+
});
|
|
118
|
+
return _signout.apply(this, arguments);
|
|
63
119
|
}
|
|
64
|
-
|
|
65
|
-
function signup(
|
|
66
|
-
|
|
67
|
-
const User = ctx.db.getRepository('users');
|
|
68
|
-
const { values } = ctx.action.params;
|
|
69
|
-
const user = yield User.create({ values });
|
|
70
|
-
ctx.body = user;
|
|
71
|
-
yield next();
|
|
72
|
-
});
|
|
120
|
+
|
|
121
|
+
function signup(_x7, _x8) {
|
|
122
|
+
return _signup.apply(this, arguments);
|
|
73
123
|
}
|
|
74
|
-
|
|
75
|
-
function
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const User = ctx.db.getCollection('users');
|
|
82
|
-
const user = yield User.model.findOne({
|
|
83
|
-
where: {
|
|
84
|
-
email,
|
|
85
|
-
},
|
|
86
|
-
});
|
|
87
|
-
if (!user) {
|
|
88
|
-
ctx.throw(401, '邮箱账号未注册');
|
|
89
|
-
}
|
|
90
|
-
user.resetToken = crypto_1.default.randomBytes(20).toString('hex');
|
|
91
|
-
yield user.save();
|
|
92
|
-
ctx.body = user;
|
|
93
|
-
yield next();
|
|
124
|
+
|
|
125
|
+
function _signup() {
|
|
126
|
+
_signup = _asyncToGenerator(function* (ctx, next) {
|
|
127
|
+
const User = ctx.db.getRepository('users');
|
|
128
|
+
const values = ctx.action.params.values;
|
|
129
|
+
const user = yield User.create({
|
|
130
|
+
values
|
|
94
131
|
});
|
|
132
|
+
ctx.body = user;
|
|
133
|
+
yield next();
|
|
134
|
+
});
|
|
135
|
+
return _signup.apply(this, arguments);
|
|
95
136
|
}
|
|
96
|
-
|
|
97
|
-
function
|
|
98
|
-
|
|
99
|
-
const { values: { email, password, resetToken }, } = ctx.action.params;
|
|
100
|
-
const User = ctx.db.getCollection('users');
|
|
101
|
-
const user = yield User.model.findOne({
|
|
102
|
-
where: {
|
|
103
|
-
email,
|
|
104
|
-
resetToken,
|
|
105
|
-
},
|
|
106
|
-
});
|
|
107
|
-
if (!user) {
|
|
108
|
-
ctx.throw(401, 'Unauthorized');
|
|
109
|
-
}
|
|
110
|
-
user.token = null;
|
|
111
|
-
user.resetToken = null;
|
|
112
|
-
user.password = password;
|
|
113
|
-
yield user.save();
|
|
114
|
-
ctx.body = user;
|
|
115
|
-
yield next();
|
|
116
|
-
});
|
|
137
|
+
|
|
138
|
+
function lostpassword(_x9, _x10) {
|
|
139
|
+
return _lostpassword.apply(this, arguments);
|
|
117
140
|
}
|
|
118
|
-
|
|
119
|
-
function
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
141
|
+
|
|
142
|
+
function _lostpassword() {
|
|
143
|
+
_lostpassword = _asyncToGenerator(function* (ctx, next) {
|
|
144
|
+
const email = ctx.action.params.values.email;
|
|
145
|
+
|
|
146
|
+
if (!email) {
|
|
147
|
+
ctx.throw(401, ctx.t('Please fill in your email address', {
|
|
148
|
+
ns: _.namespace
|
|
149
|
+
}));
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const User = ctx.db.getCollection('users');
|
|
153
|
+
const user = yield User.model.findOne({
|
|
154
|
+
where: {
|
|
155
|
+
email
|
|
156
|
+
}
|
|
133
157
|
});
|
|
158
|
+
|
|
159
|
+
if (!user) {
|
|
160
|
+
ctx.throw(401, ctx.t('The email is incorrect, please re-enter', {
|
|
161
|
+
ns: _.namespace
|
|
162
|
+
}));
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
user.resetToken = _crypto().default.randomBytes(20).toString('hex');
|
|
166
|
+
yield user.save();
|
|
167
|
+
ctx.body = user;
|
|
168
|
+
yield next();
|
|
169
|
+
});
|
|
170
|
+
return _lostpassword.apply(this, arguments);
|
|
134
171
|
}
|
|
135
|
-
|
|
136
|
-
function
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
172
|
+
|
|
173
|
+
function resetpassword(_x11, _x12) {
|
|
174
|
+
return _resetpassword.apply(this, arguments);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function _resetpassword() {
|
|
178
|
+
_resetpassword = _asyncToGenerator(function* (ctx, next) {
|
|
179
|
+
const _ctx$action$params$va = ctx.action.params.values,
|
|
180
|
+
email = _ctx$action$params$va.email,
|
|
181
|
+
password = _ctx$action$params$va.password,
|
|
182
|
+
resetToken = _ctx$action$params$va.resetToken;
|
|
183
|
+
const User = ctx.db.getCollection('users');
|
|
184
|
+
const user = yield User.model.findOne({
|
|
185
|
+
where: {
|
|
186
|
+
email,
|
|
187
|
+
resetToken
|
|
188
|
+
}
|
|
145
189
|
});
|
|
190
|
+
|
|
191
|
+
if (!user) {
|
|
192
|
+
ctx.throw(401, 'Unauthorized');
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
user.token = null;
|
|
196
|
+
user.resetToken = null;
|
|
197
|
+
user.password = password;
|
|
198
|
+
yield user.save();
|
|
199
|
+
ctx.body = user;
|
|
200
|
+
yield next();
|
|
201
|
+
});
|
|
202
|
+
return _resetpassword.apply(this, arguments);
|
|
146
203
|
}
|
|
147
|
-
|
|
148
|
-
function
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
const pwd = User.getField('password');
|
|
161
|
-
const isValid = yield pwd.verify(oldPassword, user.password);
|
|
162
|
-
if (!isValid) {
|
|
163
|
-
ctx.throw(401, '密码错误,请您重新输入');
|
|
164
|
-
}
|
|
165
|
-
user.password = newPassword;
|
|
166
|
-
user.save();
|
|
167
|
-
ctx.body = ctx.state.currentUser.toJSON();
|
|
168
|
-
yield next();
|
|
204
|
+
|
|
205
|
+
function getUserByResetToken(_x13, _x14) {
|
|
206
|
+
return _getUserByResetToken.apply(this, arguments);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function _getUserByResetToken() {
|
|
210
|
+
_getUserByResetToken = _asyncToGenerator(function* (ctx, next) {
|
|
211
|
+
const token = ctx.action.params.token;
|
|
212
|
+
const User = ctx.db.getCollection('users');
|
|
213
|
+
const user = yield User.model.findOne({
|
|
214
|
+
where: {
|
|
215
|
+
resetToken: token
|
|
216
|
+
}
|
|
169
217
|
});
|
|
218
|
+
|
|
219
|
+
if (!user) {
|
|
220
|
+
ctx.throw(401, 'Unauthorized');
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
ctx.body = user;
|
|
224
|
+
yield next();
|
|
225
|
+
});
|
|
226
|
+
return _getUserByResetToken.apply(this, arguments);
|
|
170
227
|
}
|
|
171
|
-
|
|
172
|
-
function
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
228
|
+
|
|
229
|
+
function updateProfile(_x15, _x16) {
|
|
230
|
+
return _updateProfile.apply(this, arguments);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function _updateProfile() {
|
|
234
|
+
_updateProfile = _asyncToGenerator(function* (ctx, next) {
|
|
235
|
+
const values = ctx.action.params.values;
|
|
236
|
+
|
|
237
|
+
if (!ctx.state.currentUser) {
|
|
238
|
+
ctx.throw(401, 'Unauthorized');
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
yield ctx.state.currentUser.update(values);
|
|
242
|
+
ctx.body = ctx.state.currentUser;
|
|
243
|
+
yield next();
|
|
244
|
+
});
|
|
245
|
+
return _updateProfile.apply(this, arguments);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function changePassword(_x17, _x18) {
|
|
249
|
+
return _changePassword.apply(this, arguments);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function _changePassword() {
|
|
253
|
+
_changePassword = _asyncToGenerator(function* (ctx, next) {
|
|
254
|
+
const _ctx$action$params$va2 = ctx.action.params.values,
|
|
255
|
+
oldPassword = _ctx$action$params$va2.oldPassword,
|
|
256
|
+
newPassword = _ctx$action$params$va2.newPassword;
|
|
257
|
+
|
|
258
|
+
if (!ctx.state.currentUser) {
|
|
259
|
+
ctx.throw(401, 'Unauthorized');
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
const User = ctx.db.getCollection('users');
|
|
263
|
+
const user = yield User.model.findOne({
|
|
264
|
+
where: {
|
|
265
|
+
email: ctx.state.currentUser.email
|
|
266
|
+
}
|
|
178
267
|
});
|
|
268
|
+
const pwd = User.getField('password');
|
|
269
|
+
const isValid = yield pwd.verify(oldPassword, user.password);
|
|
270
|
+
|
|
271
|
+
if (!isValid) {
|
|
272
|
+
ctx.throw(401, ctx.t('The password is incorrect, please re-enter', {
|
|
273
|
+
ns: _.namespace
|
|
274
|
+
}));
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
user.password = newPassword;
|
|
278
|
+
user.save();
|
|
279
|
+
ctx.body = ctx.state.currentUser.toJSON();
|
|
280
|
+
yield next();
|
|
281
|
+
});
|
|
282
|
+
return _changePassword.apply(this, arguments);
|
|
179
283
|
}
|
|
180
|
-
|
|
181
|
-
|
|
284
|
+
|
|
285
|
+
function setDefaultRole(_x19, _x20) {
|
|
286
|
+
return _setDefaultRole.apply(this, arguments);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function _setDefaultRole() {
|
|
290
|
+
_setDefaultRole = _asyncToGenerator(function* (ctx, next) {
|
|
291
|
+
const roleName = ctx.action.params.values.roleName;
|
|
292
|
+
yield ctx.state.currentUser.setDefaultRole(roleName);
|
|
293
|
+
ctx.body = 'ok';
|
|
294
|
+
yield next();
|
|
295
|
+
});
|
|
296
|
+
return _setDefaultRole.apply(this, arguments);
|
|
297
|
+
}
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
exports
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = {
|
|
8
|
+
name: 'rolesUsers',
|
|
9
|
+
fields: [{
|
|
10
|
+
type: 'boolean',
|
|
11
|
+
name: 'default'
|
|
12
|
+
}]
|
|
6
13
|
};
|
|
7
|
-
|
|
14
|
+
exports.default = _default;
|
package/lib/collections/users.js
CHANGED
|
@@ -1,88 +1,89 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
exports
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _default = {
|
|
8
|
+
name: 'users',
|
|
9
|
+
title: '{{t("Users")}}',
|
|
10
|
+
sortable: 'sort',
|
|
11
|
+
model: 'UserModel',
|
|
12
|
+
createdBy: true,
|
|
13
|
+
updatedBy: true,
|
|
14
|
+
fields: [{
|
|
15
|
+
name: 'id',
|
|
16
|
+
type: 'integer',
|
|
17
|
+
autoIncrement: true,
|
|
18
|
+
primaryKey: true,
|
|
19
|
+
allowNull: false,
|
|
20
|
+
uiSchema: {
|
|
21
|
+
type: 'number',
|
|
22
|
+
title: '{{t("ID")}}',
|
|
23
|
+
'x-component': 'InputNumber',
|
|
24
|
+
'x-read-pretty': true
|
|
25
|
+
},
|
|
26
|
+
interface: 'id'
|
|
27
|
+
}, {
|
|
28
|
+
interface: 'input',
|
|
29
|
+
type: 'string',
|
|
30
|
+
name: 'nickname',
|
|
31
|
+
uiSchema: {
|
|
32
|
+
type: 'string',
|
|
33
|
+
title: '{{t("Nickname")}}',
|
|
34
|
+
'x-component': 'Input'
|
|
35
|
+
}
|
|
36
|
+
}, {
|
|
37
|
+
interface: 'email',
|
|
38
|
+
type: 'string',
|
|
39
|
+
name: 'email',
|
|
40
|
+
unique: true,
|
|
41
|
+
uiSchema: {
|
|
42
|
+
type: 'string',
|
|
43
|
+
title: '{{t("Email")}}',
|
|
44
|
+
'x-component': 'Input',
|
|
45
|
+
require: true
|
|
46
|
+
}
|
|
47
|
+
}, {
|
|
48
|
+
interface: 'password',
|
|
49
|
+
type: 'password',
|
|
50
|
+
name: 'password',
|
|
51
|
+
hidden: true,
|
|
52
|
+
uiSchema: {
|
|
53
|
+
type: 'string',
|
|
54
|
+
title: '{{t("Password")}}',
|
|
55
|
+
'x-component': 'Password'
|
|
56
|
+
}
|
|
57
|
+
}, {
|
|
58
|
+
interface: 'linkTo',
|
|
59
|
+
type: 'belongsToMany',
|
|
60
|
+
name: 'roles',
|
|
61
|
+
target: 'roles',
|
|
62
|
+
foreignKey: 'userId',
|
|
63
|
+
otherKey: 'roleName',
|
|
64
|
+
sourceKey: 'id',
|
|
65
|
+
targetKey: 'name',
|
|
66
|
+
through: 'rolesUsers',
|
|
67
|
+
uiSchema: {
|
|
68
|
+
type: 'array',
|
|
69
|
+
title: '{{t("Roles")}}',
|
|
70
|
+
'x-component': 'RecordPicker',
|
|
71
|
+
'x-component-props': {
|
|
72
|
+
multiple: true,
|
|
73
|
+
fieldNames: {
|
|
74
|
+
label: 'title',
|
|
75
|
+
value: 'name'
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}, {
|
|
80
|
+
type: 'string',
|
|
81
|
+
name: 'appLang'
|
|
82
|
+
}, {
|
|
83
|
+
type: 'string',
|
|
84
|
+
name: 'resetToken',
|
|
85
|
+
unique: true,
|
|
86
|
+
hidden: true
|
|
87
|
+
}]
|
|
87
88
|
};
|
|
88
|
-
|
|
89
|
+
exports.default = _default;
|
package/lib/index.d.ts
CHANGED