Skip to content

Commit

Permalink
fix(router): router is not defined error
Browse files Browse the repository at this point in the history
  • Loading branch information
Hans Kristian Flaatten committed Jul 21, 2016
1 parent 062514a commit bb4bb7c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
16 changes: 8 additions & 8 deletions apps/email/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@ const route = new Router();

const ApiUser = require('../app/model').ApiUser;

router.get('/', (req, res) => res.redirect('/email/unsubscribe'));
route.get('/', (req, res) => res.redirect('/email/unsubscribe'));

router.get('/unsubscribe', (req, res, next) => {
route.get('/unsubscribe', (req, res, next) => {
if (req.session.auth) {
res.redirect('/profile');
} else {
next();
}
});

router.get('/unsubscribe', (req, res, next) => {
route.get('/unsubscribe', (req, res, next) => {
const error = req.session.message;

delete req.session.message;
res.render('email/unsubscribe.html', { req, error });
});

router.get('/unsubscribed', (req, res, next) => {
route.get('/unsubscribed', (req, res, next) => {
const error = {
class: 'positive',
title: 'Avmelding gjennomført',
Expand All @@ -33,7 +33,7 @@ router.get('/unsubscribed', (req, res, next) => {
res.render('email/unsubscribed.html', { req, error });
});

router.post('/unsubscribe', (req, res, next) => {
route.post('/unsubscribe', (req, res, next) => {
if (!req.body.email) {
req.session.message = {
title: 'Avmelding feilet',
Expand All @@ -57,7 +57,7 @@ router.post('/unsubscribe', (req, res, next) => {
});
});

router.get('/unsubscribe/:id', (req, res, next) => {
route.get('/unsubscribe/:id', (req, res, next) => {
ApiUser.findOne({ _id: req.params.id }, (findErr, user) => {
if (findErr) { return res.redirect(303, '/email/unsubscribe'); }
if (!user) { return res.redirect(303, '/email/unsubscribed'); }
Expand All @@ -70,6 +70,6 @@ router.get('/unsubscribe/:id', (req, res, next) => {
});
});

router.get('*', (req, res) => res.redirect('/email'));
route.get('*', (req, res) => res.redirect('/email'));

module.exports = router;
module.exports = route;
10 changes: 5 additions & 5 deletions apps/profile/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const ApiUser = require('../app/model').ApiUser;
const NTB_TOS_VERSION = process.env.NTB_TOS_VERSION || 1;

// get api user for authenticated user
router.use('/', (req, res, next) => {
route.use('/', (req, res, next) => {
const query = {
'owner.userId': req.session.auth.userId,
};
Expand All @@ -29,7 +29,7 @@ router.use('/', (req, res, next) => {
});
});

router.get('/', (req, res, next) => {
route.get('/', (req, res, next) => {
const user = req.session.auth;
const error = req.session.message;

Expand All @@ -38,7 +38,7 @@ router.get('/', (req, res, next) => {
return;
});

router.post('/link', (req, res, next) => {
route.post('/link', (req, res, next) => {
// Existing users can not link their API-key
if (!req.api.isNew) {
req.session.message = {
Expand Down Expand Up @@ -112,7 +112,7 @@ router.post('/link', (req, res, next) => {
return;
});

router.post('/', (req, res, next) => {
route.post('/', (req, res, next) => {
const user = req.session.auth;

// New User
Expand Down Expand Up @@ -166,4 +166,4 @@ router.post('/', (req, res, next) => {
return;
});

module.exports = router;
module.exports = route;

0 comments on commit bb4bb7c

Please sign in to comment.