@opensaas/keystone-nextjs-auth 22.2.2 → 22.2.3

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @opensaas-keystone/nextjs-auth
2
2
 
3
+ ## 22.2.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 415a15d: Fix the session user input so get is used correctly
8
+
3
9
  ## 22.2.2
4
10
 
5
11
  ### Patch Changes
@@ -396,10 +396,6 @@ function createAuth({
396
396
  const sudoContext = createContext({
397
397
  sudo: true
398
398
  });
399
- const session = await get({
400
- req,
401
- createContext
402
- });
403
399
 
404
400
  if (((_req$headers = req.headers) === null || _req$headers === void 0 ? void 0 : (_req$headers$authoriz = _req$headers.authorization) === null || _req$headers$authoriz === void 0 ? void 0 : _req$headers$authoriz.split(' ')[0]) === 'Bearer') {
405
401
  nextSession = await jwt.getToken({
@@ -416,7 +412,17 @@ function createAuth({
416
412
  return;
417
413
  }
418
414
 
419
- return _objectSpread(_objectSpread(_objectSpread({}, session), nextSession), {}, {
415
+ const reqWithUser = req;
416
+ reqWithUser.user = {
417
+ istKey: nextSession.listKey,
418
+ itemId: nextSession.itemId,
419
+ data: nextSession.data
420
+ };
421
+ const userSession = await get({
422
+ req: reqWithUser,
423
+ createContext
424
+ });
425
+ return _objectSpread(_objectSpread(_objectSpread({}, userSession), nextSession), {}, {
420
426
  data: nextSession.data,
421
427
  listKey: nextSession.listKey,
422
428
  itemId: nextSession.itemId
@@ -395,10 +395,6 @@ function createAuth({
395
395
  const sudoContext = createContext({
396
396
  sudo: true
397
397
  });
398
- const session = await get({
399
- req,
400
- createContext
401
- });
402
398
 
403
399
  if (((_req$headers = req.headers) === null || _req$headers === void 0 ? void 0 : (_req$headers$authoriz = _req$headers.authorization) === null || _req$headers$authoriz === void 0 ? void 0 : _req$headers$authoriz.split(' ')[0]) === 'Bearer') {
404
400
  nextSession = await jwt.getToken({
@@ -415,7 +411,17 @@ function createAuth({
415
411
  return;
416
412
  }
417
413
 
418
- return _objectSpread(_objectSpread(_objectSpread({}, session), nextSession), {}, {
414
+ const reqWithUser = req;
415
+ reqWithUser.user = {
416
+ istKey: nextSession.listKey,
417
+ itemId: nextSession.itemId,
418
+ data: nextSession.data
419
+ };
420
+ const userSession = await get({
421
+ req: reqWithUser,
422
+ createContext
423
+ });
424
+ return _objectSpread(_objectSpread(_objectSpread({}, userSession), nextSession), {}, {
419
425
  data: nextSession.data,
420
426
  listKey: nextSession.listKey,
421
427
  itemId: nextSession.itemId
@@ -363,10 +363,6 @@ function createAuth({
363
363
  const sudoContext = createContext({
364
364
  sudo: true
365
365
  });
366
- const session = await get({
367
- req,
368
- createContext
369
- });
370
366
 
371
367
  if (((_req$headers = req.headers) === null || _req$headers === void 0 ? void 0 : (_req$headers$authoriz = _req$headers.authorization) === null || _req$headers$authoriz === void 0 ? void 0 : _req$headers$authoriz.split(' ')[0]) === 'Bearer') {
372
368
  nextSession = await getToken({
@@ -383,7 +379,17 @@ function createAuth({
383
379
  return;
384
380
  }
385
381
 
386
- return _objectSpread(_objectSpread(_objectSpread({}, session), nextSession), {}, {
382
+ const reqWithUser = req;
383
+ reqWithUser.user = {
384
+ istKey: nextSession.listKey,
385
+ itemId: nextSession.itemId,
386
+ data: nextSession.data
387
+ };
388
+ const userSession = await get({
389
+ req: reqWithUser,
390
+ createContext
391
+ });
392
+ return _objectSpread(_objectSpread(_objectSpread({}, userSession), nextSession), {}, {
387
393
  data: nextSession.data,
388
394
  listKey: nextSession.listKey,
389
395
  itemId: nextSession.itemId
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opensaas/keystone-nextjs-auth",
3
- "version": "22.2.2",
3
+ "version": "22.2.3",
4
4
  "repository": "https://github.com/opensaasau/keystone-nextjs-auth",
5
5
  "license": "MIT",
6
6
  "main": "dist/opensaas-keystone-nextjs-auth.cjs.js",
package/src/index.ts CHANGED
@@ -205,7 +205,6 @@ export function createAuth<GeneratedListTypes extends BaseListTypeInfo>({
205
205
  }
206
206
  const sudoContext = createContext({ sudo: true });
207
207
 
208
- const session = await get({ req, createContext });
209
208
  if (req.headers?.authorization?.split(' ')[0] === 'Bearer') {
210
209
  nextSession = (await getToken({
211
210
  req,
@@ -225,8 +224,17 @@ export function createAuth<GeneratedListTypes extends BaseListTypeInfo>({
225
224
  ) {
226
225
  return;
227
226
  }
227
+ const reqWithUser = req as any;
228
+ reqWithUser.user = {
229
+ istKey: nextSession.listKey,
230
+ itemId: nextSession.itemId,
231
+ data: nextSession.data,
232
+ };
233
+
234
+ const userSession = await get({ req: reqWithUser, createContext });
235
+
228
236
  return {
229
- ...session,
237
+ ...userSession,
230
238
  ...nextSession,
231
239
  data: nextSession.data,
232
240
  listKey: nextSession.listKey,