UNPKG

@zeushq/nextjs-zidentity

Version:

Next.js SDK for signin in with Zeus Identity

34 lines 1.26 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var assert_1 = require("../utils/assert"); /** * @ignore */ function withApiAuthFactory(sessionCache) { var _this = this; return function (apiRoute) { return function (req, res) { return (0, tslib_1.__awaiter)(_this, void 0, void 0, function () { var session; return (0, tslib_1.__generator)(this, function (_a) { switch (_a.label) { case 0: (0, assert_1.assertReqRes)(req, res); session = sessionCache.get(req, res); if (session) { if (res.locals === undefined) res.locals = {}; res.locals.session = session; res.locals.user = session.user; } return [4 /*yield*/, apiRoute(req, res)]; case 1: _a.sent(); return [2 /*return*/]; } }); }); }; }; } exports.default = withApiAuthFactory; //# sourceMappingURL=with-api-auth-optional.js.map