 they're coming!In case you missed them the first two parts of this series of blog posts can be found by clicking Part 1 and Part 2. In Part 1 we talked about the various videos which show you how to design your Dynamic Direct Mail campaign using Hello Market. In Part 2 we discussed the data you use in your campaign which contains the details of each recipient. In this post we will be talking about checking and purchasing your campaign as well as how to manage and organise your campaigns.
Campaign Summary Page and Purchasing Your Campaign
Campaign Management
We hope you have found this series of videos useful. Click here to start creating your Dynamic Direct Mail campaign!
Q. Hang on a minute! Isn't this blog called "10 Ways To Improve Your Marketing Campaign Creation"? Why are there 11 videos here?
A. Well spotted however "10 Ways..." sounds better than "11 Ways..." - think of it as a bonus track!
Hello Market® is a registered trademark of DM Print Limited, a company registered in England No. 382357.I had a problem where without warning I couldn't get onto the network, internet WiFi, anything. DHCP just wasn't getting an address.
Using my phone to search Google, it seemed the answer was to download the combo updater and run it. Well yeah like I'm going to download a 1Gb file on my phone.
When this folder opens, delete EVERYTHING! You might need to supply your password.
~/Library/Caches - spot the "~"?
Again, delete EVERYTHING!
If the Macs battery goes completely, the clock gets reset. Even after you reset the clock, the certificates and the firewall get out of sync and suddenly all your applications, including DHCP no longer have network access.
Re-applying the combo updater also resets the firewall, which is why that works.
OSX: suddenly cannot get onto the network / intern...require('dotenv').config();
const express = require('express');
const bcrypt = require('bcrypt');
const app = express();
const formidable = require('formidable');
const path = require('path');
const bodyParser = require("body-parser");
const mongoose = require('mongoose');
const passport = require('passport');
const jwt= require('jsonwebtoken');
const jwtSimple = require('jwt-simple');
const methodOverride = require('method-override');

require('./passport-config');

mongoose.set("useFindAndModify", false);
let port = process.env.PORT || 4050;
const mongoDB = process.env.CONNECTION;

const User = require('./models/userSchema.js');
const Resource = require('./models/filterSchema.js');
const cookieParser = require('cookie-parser');

mongoose.connect(
  mongoDB,
  { useNewUrlParser: true, useUnifiedTopology: true },
  (err, client) => {
    if (err) return console.error(err);
    //check to see if connection worked.
    console.log("Connected to database");
  }
);



app.use(express.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(methodOverride('_method'));
app.use(cookieParser());


app.use(express.static(path.join(__dirname, "/public")));
app.use("/authed", passport.authenticate('jwt', {session: false}));
app.use("/authed", express.static(path.join(__dirname, "/authed")));

const db = mongoose.connection;
db.on("error", console.error.bind(console, "MongoDB connection error: "));

app.listen(port, function () {
  console.log("The server is up and running at " + port);
});

/*********INDEX*********/
app.get('/', function (req, res) {
    res.sendFile(__dirname + '/public/index.html');
    });

/*********LOGIN*********/
app.get('/login',  function (req, res) {
  res.sendFile(__dirname + '/public/login.html');
  });

app.post('/login',  (req,res,next) => {
  console.log(req.body);
  passport.authenticate(
    'local',
    { session: false },
    (error, user) => {

      if (error ||!user) {
        console.log(user);

       res.status(400).json({ error });
      }

      /** This is what ends up in our JWT */
      const payload = {
        username: user.username,
        expires: Date.now() + parseInt(process.env.JWT_EXPIRE_MS),
      };
      
      /** assigns payload to req.user */
      req.login(payload, {session: false}, (error) => {
        if (error) {
          res.status(400).send({ error });
        }

        /** generate a signed json web token and return it in the response */
        const token = jwt.sign(JSON.stringify(payload), process.env.secret);

        /** assign our jwt to the cookie */
        // console.log(token);
        res.cookie('jwt', token, { httpOnly: true});
        res.status(200).send({ token });
      });
    },
  )(req, res, next);
});

/**AUTHED HANDLING**/

app.get('/protected',
  passport.authenticate('jwt', {session: false}),
  (req, res) => {
    const { user } = req;
    
    console.log("redirect is trash");
    res.redirect( '/authed/welcome.html');

    //res.redirect('/authed/welcome.html');
  });


/*********LOGOUT*********/
app.delete('/logout', (req,res) => {
    req.logout();
    res.sendStatus(204);
});
    
/*********RESET*********/
app.get('/reset', function (req, res) {
});

app.post('/passwordreset', function (req, res) {
  if (req.body.email!== undefined) {
      var emailAddress = req.body.email;
    
      User.findOne({email: emailAddress}).exec((err, user) => {
        if((err) || (user === null))
        { 
          console.error(err);

          return res.sendFile(__dirname + '/public/403.html');

         }

      var payload = {
        id: user._id,        // User ID from database
        email: emailAddress
    };

    var token = jwtSimple.encode(payload, process.env.RESET_SECRET);

    res.send('<a href="/resetpassword/' + payload.id + '/' + token + '">Reset password</a>');

      })
  
  } else {
      res.send('Email address is missing.');
  }
});

app.get('/resetpassword/:id/:token', function(req, res) {


  var payload = jwtSimple.decode(req.params.token, process.env.RESET_SECRET);

  res.send('<form action="/resetpassword" method="POST">' +
      '<input type="hidden" name="id" value="' + payload.id + '" />' +
      '<input type="hidden" name="token" value="' + req.params.token + '" />' +
      '<input type="password" name="password" value="" placeholder="Enter your new password..." />' +
      '<input type="submit" value="Reset Password" />' +
  '</form>');
});

app.post('/resetpassword',  function(req, res) {
  User.findOne({_id: req.body.id}).exec(async (err, updatedUser)  => {
    try {  
  updatedUser.password = await <PASSWORD>.hash(req.body.password, 10);
  updatedUser.save();
  //redirect the user back to the login screen after they get the successful message
  res.redirect('/login');
    } catch {
      res.redirect('/reset.html')
    }

  })
  
});

/*********REGISTER*********/
app.get('/register',  function (req, res) {
    res.sendFile(__dirname + '/public/register.html');
    });
app.post('/register',  async function (req,res) {

  try {
    req.body.password = await bcrypt.hash(req.body.password, 10);
    var newUser = new User(req.body);
    newUser.save(