@dwp/govuk-casa
Version:
A framework for building GOVUK Collect-And-Submit-Applications
23 lines • 1.24 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const logger_js_1 = __importDefault(require("../../../lib/logger.js"));
const utils_js_1 = require("./utils.js");
const log = (0, logger_js_1.default)("lib:internal-plugin:edit-snapshot:post-steer-hook");
exports.default = (req, res, next) => {
// Snapshot purging is carried out here rather than in the presteer hook,
// because the `middleware/steer-journey.js` middleware first needs the opportunity
// to redirect if the journey cannot be traversed to the edit origin.
// eslint-disable-next-line security/detect-object-injection
if (req.casa[utils_js_1.FLAG_FOR_PURGING] === true) {
log.debug(`Snapshot purging flag has been set for context '${req.casa.journeyContext.identity.id}'. Snapshot will be deleted.`);
(0, utils_js_1.deleteSnapshot)(log, req);
// eslint-disable-next-line security/detect-object-injection
req.casa[utils_js_1.FLAG_FOR_PURGING] = false;
return req.session.save(next);
}
next();
};
//# sourceMappingURL=post-steer-hook.js.map