@lowdefy/api 4.0.0-alpha.21 → 4.0.0-alpha.24

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.
@@ -12,9 +12,16 @@
12
12
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
- */ function addUserFieldsToSession(context, { session , token , authConfig }) {
16
- Object.keys(authConfig.userFields).forEach((fieldName)=>{
17
- session.user[fieldName] = token[fieldName];
18
- });
15
+ */ function addUserFieldsToSession(context, { session , token , authConfig , user }) {
16
+ if (token) {
17
+ Object.keys(authConfig.userFields).forEach((fieldName)=>{
18
+ session.user[fieldName] = token[fieldName];
19
+ });
20
+ }
21
+ if (user) {
22
+ Object.keys(authConfig.userFields).forEach((fieldName)=>{
23
+ session.user[fieldName] = user[fieldName];
24
+ });
25
+ }
19
26
  }
20
27
  export default addUserFieldsToSession;
@@ -46,13 +46,14 @@ function createSessionCallback(context, { authConfig , plugins }) {
46
46
  updated_at,
47
47
  ...session.user
48
48
  };
49
- if (authConfig.userFields) {
50
- addUserFieldsToSession(context, {
51
- authConfig,
52
- session,
53
- token
54
- });
55
- }
49
+ }
50
+ if (authConfig.userFields) {
51
+ addUserFieldsToSession(context, {
52
+ authConfig,
53
+ session,
54
+ token,
55
+ user
56
+ });
56
57
  }
57
58
  for (const plugin of sessionCallbackPlugins){
58
59
  // eslint-disable-next-line no-param-reassign
@@ -0,0 +1,24 @@
1
+ /*
2
+ Copyright 2020-2022 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ function createAdapter(context, { authConfig , plugins }) {
16
+ const adapterConfig = authConfig.adapter;
17
+ if (!adapterConfig) {
18
+ return undefined;
19
+ }
20
+ return plugins.adapters[adapterConfig.type]({
21
+ properties: adapterConfig.properties
22
+ });
23
+ }
24
+ export default createAdapter;
@@ -15,6 +15,7 @@
15
15
  */ import { NodeParser } from '@lowdefy/operators';
16
16
  import { getSecretsFromEnv } from '@lowdefy/node-utils';
17
17
  import { _secret } from '@lowdefy/operators-js/operators/server';
18
+ import createAdapter from './createAdapter.js';
18
19
  import createCallbacks from './callbacks/createCallbacks.js';
19
20
  import createEvents from './events/createEvents.js';
20
21
  import createProviders from './createProviders.js';
@@ -39,6 +40,10 @@ function getNextAuthConfig(context, { authJson , plugins }) {
39
40
  if (operatorErrors.length > 0) {
40
41
  throw new Error(operatorErrors[0]);
41
42
  }
43
+ nextAuthConfig.adapter = createAdapter(context, {
44
+ authConfig,
45
+ plugins
46
+ });
42
47
  nextAuthConfig.callbacks = createCallbacks(context, {
43
48
  authConfig,
44
49
  plugins
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/api",
3
- "version": "4.0.0-alpha.21",
3
+ "version": "4.0.0-alpha.24",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -41,12 +41,12 @@
41
41
  "test": "yarn node --experimental-vm-modules $(yarn bin jest)"
42
42
  },
43
43
  "dependencies": {
44
- "@lowdefy/ajv": "4.0.0-alpha.21",
45
- "@lowdefy/helpers": "4.0.0-alpha.21",
46
- "@lowdefy/node-utils": "4.0.0-alpha.21",
47
- "@lowdefy/nunjucks": "4.0.0-alpha.21",
48
- "@lowdefy/operators": "4.0.0-alpha.21",
49
- "@lowdefy/operators-js": "4.0.0-alpha.21"
44
+ "@lowdefy/ajv": "4.0.0-alpha.24",
45
+ "@lowdefy/helpers": "4.0.0-alpha.24",
46
+ "@lowdefy/node-utils": "4.0.0-alpha.24",
47
+ "@lowdefy/nunjucks": "4.0.0-alpha.24",
48
+ "@lowdefy/operators": "4.0.0-alpha.24",
49
+ "@lowdefy/operators-js": "4.0.0-alpha.24"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@jest/globals": "28.1.0",
@@ -58,5 +58,5 @@
58
58
  "publishConfig": {
59
59
  "access": "public"
60
60
  },
61
- "gitHead": "748794b56e36b9b63b8942a235b16e98c00e4e83"
61
+ "gitHead": "7ae69eeb9a93964e2fb0bf08b7a21bee2636a630"
62
62
  }