@kne/fastify-account 2.0.0-alpha.0 → 2.0.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/index.js +4 -1
- package/libs/services/account.js +3 -3
- package/libs/services/admin.js +2 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -17,7 +17,10 @@ const user = fp(
|
|
|
17
17
|
isTest: false,
|
|
18
18
|
jwt: {
|
|
19
19
|
secret: 'super-secret',
|
|
20
|
-
expires: null
|
|
20
|
+
expires: null,
|
|
21
|
+
verify: {
|
|
22
|
+
extractToken: request => request.headers['x-user-token']
|
|
23
|
+
}
|
|
21
24
|
},
|
|
22
25
|
defaultPassword: 'Aa000000!',
|
|
23
26
|
sendMessage: async () => {}
|
package/libs/services/account.js
CHANGED
|
@@ -160,13 +160,13 @@ const accountService = fp(async (fastify, options) => {
|
|
|
160
160
|
await passwordAuthentication({ accountId: user.userAccountId, password });
|
|
161
161
|
|
|
162
162
|
return {
|
|
163
|
-
token: fastify.jwt.sign({ payload: { id: user.
|
|
164
|
-
user: Object.assign({}, user.get({ plain: true }), { id: user.
|
|
163
|
+
token: fastify.jwt.sign({ payload: { id: user.id } }),
|
|
164
|
+
user: Object.assign({}, user.get({ plain: true }), { id: user.id })
|
|
165
165
|
};
|
|
166
166
|
};
|
|
167
167
|
|
|
168
168
|
const resetPassword = async ({ password, userId }) => {
|
|
169
|
-
const user = await services.user.getUserInstance({
|
|
169
|
+
const user = await services.user.getUserInstance({ id: userId });
|
|
170
170
|
const account = await models.userAccount.create(
|
|
171
171
|
Object.assign({}, await passwordEncryption(password), {
|
|
172
172
|
belongToUserId: user.id
|
package/libs/services/admin.js
CHANGED
|
@@ -11,13 +11,13 @@ const adminService = fp(async (fastify, options) => {
|
|
|
11
11
|
})) > 0) {
|
|
12
12
|
throw new Error('系统已经初始化完成,不能执行该操作');
|
|
13
13
|
}
|
|
14
|
-
const currentUser = await services.user.getUserInstance({
|
|
14
|
+
const currentUser = await services.user.getUserInstance({id: user.id});
|
|
15
15
|
currentUser.isSuperAdmin = true;
|
|
16
16
|
await currentUser.save();
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
const checkIsSuperAdmin = async (user) => {
|
|
20
|
-
const currentUser = await services.user.getUserInstance({
|
|
20
|
+
const currentUser = await services.user.getUserInstance({id: user.id});
|
|
21
21
|
return currentUser.isSuperAdmin === true;
|
|
22
22
|
};
|
|
23
23
|
|