@niledatabase/server 3.0.0-alpha.1 → 3.0.0-alpha.2

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.
@@ -6,7 +6,7 @@
6
6
  * - users
7
7
  * summary: lists users in the tenant
8
8
  * description: Returns information about the users within the tenant
9
- * provided. You can also pass the a `niledb-tenantId` in the header or in a cookie.
9
+ * provided. You can also pass the a `niledb-tenant-id` in the header or in a cookie.
10
10
  * operationId: listUsers
11
11
  * parameters:
12
12
  * - name: tenantId
@@ -2,5 +2,13 @@ import { Config } from '../../utils/Config';
2
2
  export type ActiveSession = {
3
3
  id: string;
4
4
  email: string;
5
+ expires: Date;
6
+ user?: {
7
+ id: string;
8
+ name: string;
9
+ image: string;
10
+ email: string;
11
+ emailVerified: void | Date;
12
+ };
5
13
  };
6
14
  export default function auth(req: Request, config: Config): Promise<void | ActiveSession>;
@@ -2262,30 +2262,32 @@ function _auth() {
2262
2262
  while (1) switch (_context.prev = _context.next) {
2263
2263
  case 0:
2264
2264
  _Logger = Logger(_extends({}, config, {
2265
- debug: true
2265
+ debug: config.debug
2266
2266
  }), '[nileauth]'), info = _Logger.info;
2267
2267
  info('checking auth');
2268
2268
  sessionUrl = config.api.basePath + "/auth/session";
2269
2269
  info('using session', sessionUrl);
2270
- _context.next = 6;
2270
+ // handle the pass through with posts
2271
+ req.headers["delete"]('content-length');
2272
+ _context.next = 7;
2271
2273
  return request(sessionUrl, {
2272
2274
  request: req
2273
2275
  });
2274
- case 6:
2276
+ case 7:
2275
2277
  res = _context.sent;
2276
2278
  if (res) {
2277
- _context.next = 10;
2279
+ _context.next = 11;
2278
2280
  break;
2279
2281
  }
2280
2282
  info('no session found');
2281
2283
  return _context.abrupt("return", undefined);
2282
- case 10:
2284
+ case 11:
2283
2285
  info('session active');
2284
- _context.next = 13;
2286
+ _context.next = 14;
2285
2287
  return new Response(res.body).json();
2286
- case 13:
2287
- return _context.abrupt("return", _context.sent);
2288
2288
  case 14:
2289
+ return _context.abrupt("return", _context.sent);
2290
+ case 15:
2289
2291
  case "end":
2290
2292
  return _context.stop();
2291
2293
  }
@@ -2401,7 +2403,7 @@ function _POST$2() {
2401
2403
  * - users
2402
2404
  * summary: lists users in the tenant
2403
2405
  * description: Returns information about the users within the tenant
2404
- * provided. You can also pass the a `niledb-tenantId` in the header or in a cookie.
2406
+ * provided. You can also pass the a `niledb-tenant-id` in the header or in a cookie.
2405
2407
  * operationId: listUsers
2406
2408
  * parameters:
2407
2409
  * - name: tenantId
@@ -2963,17 +2965,21 @@ function GET(_x, _x2, _x3) {
2963
2965
  }
2964
2966
  function _GET() {
2965
2967
  _GET = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(session, init, log) {
2966
- var url;
2968
+ var url, res;
2967
2969
  return _regeneratorRuntime().wrap(function _callee$(_context) {
2968
2970
  while (1) switch (_context.prev = _context.next) {
2969
2971
  case 0:
2970
2972
  url = "" + apiRoutes.USER_TENANTS(session.id);
2973
+ if (typeof session === 'object' && 'user' in session && session.user) {
2974
+ url = "" + apiRoutes.USER_TENANTS(session.user.id);
2975
+ }
2971
2976
  log('[GET]', url);
2972
- _context.next = 4;
2977
+ _context.next = 5;
2973
2978
  return request(url, init);
2974
- case 4:
2975
- return _context.abrupt("return", _context.sent);
2976
2979
  case 5:
2980
+ res = _context.sent;
2981
+ return _context.abrupt("return", res);
2982
+ case 7:
2977
2983
  case "end":
2978
2984
  return _context.stop();
2979
2985
  }