@kne/fastify-account 1.0.0-alpha.3 → 1.0.0-alpha.5

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 CHANGED
@@ -22,7 +22,7 @@ npm i --save @kne/fastify-account
22
22
  ### API
23
23
 
24
24
  ---
25
- title: "@kne/fastify-account v1.0.0-alpha.3"
25
+ title: "@kne/fastify-account v1.0.0-alpha.4"
26
26
  language_tabs:
27
27
  - shell: Shell
28
28
  - http: HTTP
@@ -42,7 +42,7 @@ headingLevel: 2
42
42
 
43
43
  <!-- Generator: Widdershins v4.0.1 -->
44
44
 
45
- <h1 id="-kne-fastify-account">@kne/fastify-account v1.0.0-alpha.3</h1>
45
+ <h1 id="-kne-fastify-account">@kne/fastify-account v1.0.0-alpha.4</h1>
46
46
 
47
47
  > Scroll down for code samples, example requests and responses. Select a language for code samples from the tabs above or the mobile navigation menu.
48
48
 
@@ -27,7 +27,7 @@ module.exports = fp(async (fastify, options) => {
27
27
  onRequest: [authenticate.user, authenticate.tenant]
28
28
  },
29
29
  async request => {
30
- const { tenantId } = request.tenantInfo;
30
+ const { id: tenantId } = request.tenantInfo.tenant;
31
31
  return await services.tenantOrg.getTenantOrgList({ tenantId });
32
32
  }
33
33
  );
@@ -67,11 +67,11 @@ module.exports = fp(async (fastify, options) => {
67
67
  };
68
68
 
69
69
  const getTenantOrgList = async ({ tenantId }) => {
70
- const { count, rows } = await models.tenantOrg.findAndCountAll({
70
+ const data = await models.tenantOrg.findAll({
71
71
  where: { tenantId }
72
72
  });
73
73
 
74
- return { pageData: rows, totalCount: count };
74
+ return data.map(item => item.get({ plain: true }));
75
75
  };
76
76
 
77
77
  services.tenantOrg = {
@@ -116,8 +116,8 @@ module.exports = fp(async (fastify, options) => {
116
116
  const currentTenant = currentTenantUser && tenantList.find(({ uuid }) => uuid === currentTenantUser.tenantId);
117
117
 
118
118
  return {
119
- currentTenant: currentTenant && Object.assign({}, currentTenant, { id: currentTenant.uuid }),
120
- currentTenantUser: currentTenantUser && Object.assign({}, currentTenantUser, { id: currentTenantUser.uuid }),
119
+ currentTenant: currentTenant && Object.assign({}, currentTenant.get({ plain: true }), { id: currentTenant.uuid }),
120
+ currentTenantUser: currentTenantUser && Object.assign({}, currentTenantUser.get({ plain: true }), { id: currentTenantUser.uuid }),
121
121
  tenantList: tenantList.map(item => {
122
122
  return Object.assign({}, item.get({ plain: true }), { id: item.uuid });
123
123
  }),
@@ -148,7 +148,7 @@ module.exports = fp(async (fastify, options) => {
148
148
  const tenant = await services.tenant.getTenant({ id: user.currentTenantId });
149
149
 
150
150
  const tenantUser = await models.tenantUser.findOne({
151
- attributes: ['uuid', 'avatar', 'description', 'phone', 'email'],
151
+ attributes: ['uuid', 'avatar', 'name', 'description', 'phone', 'email'],
152
152
  include: [
153
153
  {
154
154
  attributes: ['id', 'name'],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kne/fastify-account",
3
- "version": "1.0.0-alpha.3",
3
+ "version": "1.0.0-alpha.5",
4
4
  "description": "fastify的用户管理账号等实现",
5
5
  "main": "index.js",
6
6
  "scripts": {