@kne/fastify-account 2.0.0-alpha.4 → 2.0.0-alpha.6

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
@@ -1,6 +1,6 @@
1
1
  const fp = require('fastify-plugin');
2
2
  const path = require('node:path');
3
- const {merge } = require('lodash');
3
+ const { merge } = require('lodash');
4
4
  const jwt = require('@fastify/jwt');
5
5
  const namespace = require('@kne/fastify-namespace');
6
6
  const httpErrors = require('http-errors');
@@ -8,7 +8,7 @@ const httpErrors = require('http-errors');
8
8
  const { Unauthorized } = httpErrors;
9
9
 
10
10
  const user = fp(
11
- async function (fastify, options) {
11
+ async function(fastify, options) {
12
12
  options = merge(
13
13
  {
14
14
  name: 'account',
@@ -19,11 +19,12 @@ const user = fp(
19
19
  secret: 'super-secret',
20
20
  expires: null,
21
21
  verify: {
22
- extractToken: request => request.headers['x-user-token']
22
+ extractToken: request => request.headers['x-user-token'] || request.query?.token
23
23
  }
24
24
  },
25
25
  defaultPassword: 'Aa000000!',
26
- sendMessage: async () => {}
26
+ sendMessage: async () => {
27
+ }
27
28
  },
28
29
  options
29
30
  );
@@ -33,7 +33,8 @@ const accountController = fp(async (fastify, options) => {
33
33
  schema: {
34
34
  tags: ['账号'], summary: '发送登录短信验证码', body: {
35
35
  type: 'object', required: ['phone'], properties: {
36
- phone: { type: 'string', description: '电话' }
36
+ phone: { type: 'string', description: '电话' },
37
+ type: { type: 'number', description: '0:注册,2:登录,4:验证租户管理员,5:忘记密码', default: 0 }
37
38
  }
38
39
  }, response: {
39
40
  200: {
@@ -50,8 +51,8 @@ const accountController = fp(async (fastify, options) => {
50
51
  }
51
52
  }
52
53
  }, async request => {
53
- const { phone } = request.body;
54
- const code = await services.account.sendVerificationCode({ name: phone, type: 0 });
54
+ const { phone, type } = request.body;
55
+ const code = await services.account.sendVerificationCode({ name: phone, type });
55
56
  return options.isTest ? { code } : {};
56
57
  });
57
58
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kne/fastify-account",
3
- "version": "2.0.0-alpha.4",
3
+ "version": "2.0.0-alpha.6",
4
4
  "description": "用于用户注册登录认证.",
5
5
  "main": "index.js",
6
6
  "scripts": {