@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 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 () => {}
@@ -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.uuid } }),
164
- user: Object.assign({}, user.get({ plain: true }), { id: user.uuid })
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({ uuid: userId });
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
@@ -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({uuid: user.id});
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({uuid: user.id});
20
+ const currentUser = await services.user.getUserInstance({id: user.id});
21
21
  return currentUser.isSuperAdmin === true;
22
22
  };
23
23
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kne/fastify-account",
3
- "version": "2.0.0-alpha.0",
3
+ "version": "2.0.0-alpha.1",
4
4
  "description": "用于用户注册登录认证.",
5
5
  "main": "index.js",
6
6
  "scripts": {