Skip to content

Commit

Permalink
Delete old "user_dashboard" and "full_report" routes.
Browse files Browse the repository at this point in the history
  • Loading branch information
lesleyjanenorton committed Apr 3, 2019
1 parent 461351f commit 4ec56c9
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 43 deletions.
2 changes: 1 addition & 1 deletion controllers/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async function home(req, res) {
let scanFeaturedBreach = false;

if (req.session.user && !req.query.breach) {
return res.redirect("/scan/user_dashboard");
return res.redirect("/user/dashboard");
}

if (req.query.breach) {
Expand Down
39 changes: 2 additions & 37 deletions controllers/scan.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,53 +73,18 @@ async function post (req, res) {
};

if (req.session.user && scanRes.selfScan && !req.body.featuredBreach) {
return res.redirect("/scan/user_dashboard");
return res.redirect("/user/dashboard");
}
res.render("scan", Object.assign(scanRes, formTokens));
}


async function getFullReport(req, res) {
if (!req.session.user) {
return res.redirect("/");
}

const scanRes = await scanResult(req, true);
res.render("scan", scanRes);
}



async function getUserDashboard(req, res) {

if (!req.session.user) {
return res.redirect("/");
}

const formTokens = {
pageToken: AppConstants.PAGE_TOKEN_TIMER > 0 ? generatePageToken(req) : "",
csrfToken: req.csrfToken(),
};

const scanRes = await scanResult(req, true);
scanRes.newUser = false;

if (req.session.newUser === true) {
scanRes.newUser = true;
req.session.newUser = false;
}

return res.render("scan", Object.assign(scanRes, formTokens));
}


function get (req, res) {
res.redirect("/");
}


module.exports = {
post,
get,
getFullReport,
getUserDashboard,
};
6 changes: 2 additions & 4 deletions routes/scan.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const express = require("express");
const bodyParser = require("body-parser");
const csrf = require("csurf");

const {asyncMiddleware} = require("../middleware");
const {post, get, getFullReport, getUserDashboard} = require("../controllers/scan");
const { asyncMiddleware } = require("../middleware");
const { post, get } = require("../controllers/scan");

const router = express.Router();
const urlEncodedParser = bodyParser.urlencoded({ extended: false });
Expand All @@ -14,7 +14,5 @@ const csrfProtection = csrf();

router.post("/", urlEncodedParser, csrfProtection, asyncMiddleware(post));
router.get("/", get);
router.get("/full_report", getFullReport);
router.get("/user_dashboard", urlEncodedParser, csrfProtection, asyncMiddleware(getUserDashboard));

module.exports = router;
2 changes: 1 addition & 1 deletion tests/controllers/oauth.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ test("confirmed request checks session cookie, calls FXA for token and email, ad
expect(subscribers[0].signup_language).toBe(userAddLanguages);

const mockRedirectCallArgs = mockResponse.redirect.mock.calls[0];
expect(mockRedirectCallArgs[0]).toBe("/scan/user_dashboard");
expect(mockRedirectCallArgs[0]).toBe("/user/dashboard");
});


Expand Down

0 comments on commit 4ec56c9

Please sign in to comment.