Skip to content

Commit

Permalink
Reroute and update breach details pages. WIP.
Browse files Browse the repository at this point in the history
  • Loading branch information
lesleyjanenorton committed May 6, 2019
1 parent 9926ada commit 03a3714
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 11 deletions.
23 changes: 23 additions & 0 deletions controllers/breach-details.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"use strict";

const HIBP = require("../hibp");

function getBreachDetail(req, res) {

const allBreaches = req.app.locals.breaches;

const breachName = req.params.breachName;
const featuredBreach = HIBP.getBreachByName(allBreaches, breachName);

if (!featuredBreach) {
res.redirect("/");
}

res.render("breach-detail", {
featuredBreach,
});
}

module.exports = {
getBreachDetail,
};
2 changes: 1 addition & 1 deletion controllers/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async function home(req, res) {
}
scanFeaturedBreach = true;

return res.render("breach-detail", {
return res.render("monitor", {
title: req.fluentFormat("home-title"),
featuredBreach: featuredBreach,
scanFeaturedBreach,
Expand Down
10 changes: 10 additions & 0 deletions routes/breach-details.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"use strict";

const express = require("express");
const { getBreachDetail } = require("../controllers/breach-details");
const router = express.Router();


router.get("/:breachName", getBreachDetail);

module.exports = router;
2 changes: 2 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const SesRoutes = require("./routes/ses");
const OAuthRoutes = require("./routes/oauth");
const UserRoutes = require("./routes/user");
const EmailL10nRoutes= require("./routes/email-l10n");
const BreachRoutes= require("./routes/breach-details");

const log = mozlog("server");
const app = express();
Expand Down Expand Up @@ -172,6 +173,7 @@ app.use("/scan", ScanRoutes);
app.use("/ses", SesRoutes);
app.use("/user", UserRoutes);
(devOrHeroku ? app.use("/email-l10n", EmailL10nRoutes) : null);
app.use("/breach-details", BreachRoutes);
app.use("/", HomeRoutes);

app.use(logErrors);
Expand Down
20 changes: 10 additions & 10 deletions template-helpers/breach-detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,22 @@ function getSensitiveBreachContent(locales, breach) {
function getTips(locales, breach) {
const tips = [
{
title: "create-pw",
subtitle: "strength-of-your",
linkTitle: "how-to-create",
href: "/create-strong-passwords",
title: "stop-reusing-pw",
subtitle: "create-unique-pw",
linkTitle: "five-myths",
href: "",
},
{
title: "stop-using",
subtitle: "get-help-managing",
linkTitle: "why-password-managers",
href: "/password-managers",
title: "make-new-pw-unique",
subtitle: "strength-of-your-pw",
linkTitle: "create-strong-passwords",
href: "",
},
{
title: "change-pw",
subtitle: "even-for-old",
linkTitle: "what-to-do-after",
href: "/what-to-do",
linkTitle: "what-to-do-after-breach",
href: "",
},
];
tips.forEach(tip => {
Expand Down

0 comments on commit 03a3714

Please sign in to comment.