-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7f22e2f
commit 837fb44
Showing
16 changed files
with
547 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.updateConfirmationEmail = exports.getConfirmationEmail = void 0; | ||
const express_validator_1 = require("express-validator"); | ||
const sanitize_html_1 = __importDefault(require("sanitize-html")); | ||
const confirmationEmails_1 = require("../services/confirmationEmails"); | ||
const validationErrorParser_1 = __importDefault(require("../util/validationErrorParser")); | ||
/** | ||
* Retrieves the VSR confirmation email from the database. | ||
*/ | ||
const getConfirmationEmail = (req, res, next) => __awaiter(void 0, void 0, void 0, function* () { | ||
try { | ||
const confirmationEmail = yield (0, confirmationEmails_1.retrieveConfirmaionEmail)(); | ||
res.status(200).json({ html: confirmationEmail.html, papLogoHTML: confirmationEmails_1.PAP_LOGO_HTML }); | ||
} | ||
catch (error) { | ||
next(error); | ||
} | ||
}); | ||
exports.getConfirmationEmail = getConfirmationEmail; | ||
const updateConfirmationEmail = (req, res, next) => __awaiter(void 0, void 0, void 0, function* () { | ||
const errors = (0, express_validator_1.validationResult)(req); | ||
try { | ||
(0, validationErrorParser_1.default)(errors); | ||
const { html } = req.body; | ||
const sanitizedHTML = (0, sanitize_html_1.default)(html, { | ||
allowedTags: sanitize_html_1.default.defaults.allowedTags.concat([ | ||
// Frontend editor uses <ins> tags for underlining. | ||
"ins", | ||
]), | ||
}); | ||
const updatedConfirmationEmail = yield (0, confirmationEmails_1.updateConfirmationEmail)(sanitizedHTML); | ||
res.status(200).json(updatedConfirmationEmail); | ||
} | ||
catch (error) { | ||
next(error); | ||
} | ||
}); | ||
exports.updateConfirmationEmail = updateConfirmationEmail; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const mongoose_1 = require("mongoose"); | ||
/** | ||
* A model for the confirmation email sent to veterans when they fill out the | ||
* VSR. Only one instance of this model will ever exist at once. | ||
*/ | ||
const confirmationEmailSchema = new mongoose_1.Schema({ | ||
// The HTML of the email | ||
html: { type: String, required: true }, | ||
}); | ||
exports.default = (0, mongoose_1.model)("ConfirmationEmail", confirmationEmailSchema); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const express_1 = __importDefault(require("express")); | ||
const auth_1 = require("../middleware/auth"); | ||
const ConfirmationEmailController = __importStar(require("../controllers/confirmationEmail")); | ||
const ConfirmationEmailValidator = __importStar(require("../validators/confirmationEmail")); | ||
const router = express_1.default.Router(); | ||
router.get("/", auth_1.requireSignedIn, auth_1.requireAdmin, ConfirmationEmailController.getConfirmationEmail); | ||
router.put("/", auth_1.requireSignedIn, auth_1.requireAdmin, ConfirmationEmailValidator.updateConfirmationEmail, ConfirmationEmailController.updateConfirmationEmail); | ||
exports.default = router; |
Oops, something went wrong.