在heroku上部署后,节点js应用程序的重置链接不起作用

时间:2019-01-09 08:11:37

标签: heroku

当我在本地运行应用程序时,yelpcamp的重置功能运行正常,但是当我在heroku上部署它时,则无法正常工作。

当我在本地运行我的应用程序时,它运行良好,但是当我在heroku上部署它时,它显示了内部服务器错误。

heroku日志

deepak@deepak-Latitude-E5440:~/Desktop/youtube$ heroku logs -t
2019-01-07T05:41:59.113006+00:00 app[web.1]: 
2019-01-07T05:42:00.083906+00:00 heroku[web.1]: State changed from starting to up
2019-01-07T05:41:59.985120+00:00 app[web.1]: Warning: connect.session() MemoryStore is not
2019-01-07T05:41:59.985145+00:00 app[web.1]: designed for a production environment, as it will leak
2019-01-07T05:41:59.985148+00:00 app[web.1]: memory, and will not scale past a single process.
2019-01-07T05:41:59.993280+00:00 app[web.1]: (node:23) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
2019-01-07T05:41:59.994441+00:00 app[web.1]: server started
2019-01-07T05:42:00.079169+00:00 app[web.1]: (node:23) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.
2019-01-07T05:42:35.613431+00:00 app[api]: Set GMAIL_SMTP_PASSWORD config vars by user sangambagbay@gmail.com
2019-01-07T05:42:36.020056+00:00 heroku[web.1]: Restarting
2019-01-07T05:42:36.044102+00:00 heroku[web.1]: State changed from up to starting
2019-01-07T05:42:37.178756+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2019-01-07T05:42:37.291295+00:00 heroku[web.1]: Process exited with status 143
2019-01-07T05:42:39.577374+00:00 heroku[web.1]: Starting process with command `npm start`
2019-01-07T05:42:43.865682+00:00 heroku[web.1]: State changed from starting to up
2019-01-07T05:42:43.821908+00:00 app[web.1]: Warning: connect.session() MemoryStore is not
2019-01-07T05:42:43.821957+00:00 app[web.1]: designed for a production environment, as it will leak
2019-01-07T05:42:43.821958+00:00 app[web.1]: memory, and will not scale past a single process.
2019-01-07T05:42:43.829664+00:00 app[web.1]: (node:23) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
2019-01-07T05:42:43.830709+00:00 app[web.1]: server started
2019-01-07T05:42:43.910869+00:00 app[web.1]: (node:23) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.
2019-01-07T05:42:45.472748+00:00 heroku[router]: at=info method=GET path="/forgot" host=protected-thicket-41413.herokuapp.com request_id=b9f4426a-9280-4cfc-8357-4933b41cf941 fwd="47.31.118.185" dyno=web.1 connect=1ms service=43ms status=304 bytes=276 protocol=https
2019-01-07T05:42:49.992974+00:00 heroku[router]: at=info method=POST path="/forgot" host=protected-thicket-41413.herokuapp.com request_id=b7089a6f-bb36-429e-8bfa-d3f7c6a8a461 fwd="47.31.118.185" dyno=web.1 connect=0ms service=720ms status=500 bytes=404 protocol=https
2019-01-07T05:44:56.000000+00:00 app[api]: Build started by user sangambagbay@gmail.com
2019-01-07T05:45:12.859716+00:00 heroku[web.1]: Restarting
2019-01-07T05:45:12.863674+00:00 heroku[web.1]: State changed from up to starting
2019-01-07T05:45:13.970571+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2019-01-07T05:45:14.098161+00:00 heroku[web.1]: Process exited with status 143
2019-01-07T05:45:16.138971+00:00 heroku[web.1]: Starting process with command `npm start`
2019-01-07T05:45:12.688292+00:00 app[api]: Deploy 106da843 by user sangambagbay@gmail.com
2019-01-07T05:45:13.000000+00:00 app[api]: Build succeeded
2019-01-07T05:45:12.688292+00:00 app[api]: Release v10 created by user sangambagbay@gmail.com
2019-01-07T05:45:19.527546+00:00 app[web.1]: 
2019-01-07T05:45:19.527579+00:00 app[web.1]: > youtube@1.0.0 start /app
2019-01-07T05:45:19.527581+00:00 app[web.1]: > node app.js
2019-01-07T05:45:19.527582+00:00 app[web.1]: 
2019-01-07T05:45:20.962114+00:00 app[web.1]: Warning: connect.session() MemoryStore is not
2019-01-07T05:45:20.962153+00:00 app[web.1]: designed for a production environment, as it will leak
2019-01-07T05:45:20.962155+00:00 app[web.1]: memory, and will not scale past a single process.
2019-01-07T05:45:20.973398+00:00 app[web.1]: (node:23) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
2019-01-07T05:45:20.975351+00:00 app[web.1]: server started
2019-01-07T05:45:21.069231+00:00 app[web.1]: (node:23) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.
2019-01-07T05:45:21.645109+00:00 heroku[web.1]: State changed from starting to up
2019-01-07T05:45:28.389600+00:00 heroku[router]: at=info method=GET path="/forgot" host=protected-thicket-41413.herokuapp.com request_id=dd913a2c-a3ea-4131-a66b-020dcce78009 fwd="47.31.118.185" dyno=web.1 connect=0ms service=85ms status=304 bytes=284 protocol=https
2019-01-07T05:45:29.550787+00:00 heroku[router]: at=info method=GET path="/stylesheet/header.css" host=protected-thicket-41413.herokuapp.com request_id=c749ee20-a0de-4c66-936e-1e49a457efc7 fwd="47.31.118.185" dyno=web.1 connect=1ms service=17ms status=200 bytes=5435 protocol=https
2019-01-07T05:45:32.464223+00:00 heroku[router]: at=info method=POST path="/forgot" host=protected-thicket-41413.herokuapp.com request_id=8ec1c9e3-a24d-4c04-8ce6-e932aed749d1 fwd="47.31.118.185" dyno=web.1 connect=1ms service=764ms status=500 bytes=404 protocol=https
2019-01-07T06:19:18.638532+00:00 heroku[web.1]: State changed from up to down
2019-01-07T06:19:19.653718+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2019-01-07T06:19:19.805011+00:00 heroku[web.1]: Process exited with status 143
2019-01-09T07:16:32.405311+00:00 app[web.1]: 
2019-01-09T07:16:32.405330+00:00 app[web.1]: > youtube@1.0.0 start /app
2019-01-09T07:16:32.405332+00:00 app[web.1]: > node app.js
2019-01-09T07:16:32.405333+00:00 app[web.1]: 
2019-01-09T07:16:34.697140+00:00 heroku[router]: at=info method=GET path="/" host=protected-thicket-41413.herokuapp.com request_id=db4d597f-8f16-4d09-a5d8-fae485f8b57d fwd="47.31.91.80" dyno=web.1 connect=0ms service=60ms status=304 bytes=288 protocol=https
2019-01-09T07:16:35.180993+00:00 heroku[router]: at=info method=GET path="/stylesheet/landing.css" host=protected-thicket-41413.herokuapp.com request_id=f7e6864d-3652-4b28-9dfb-9f0d83d5a40f fwd="47.31.91.80" dyno=web.1 connect=0ms service=6ms status=304 bytes=238 protocol=https
2019-01-09T07:16:37.887015+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=protected-thicket-41413.herokuapp.com request_id=d6733f50-98d0-40a6-8a1e-4f71c3173dd0 fwd="47.31.91.80" dyno=web.1 connect=0ms service=17ms status=404 bytes=394 protocol=https
2019-01-09T07:16:43.291070+00:00 heroku[router]: at=info method=GET path="/forgot" host=protected-thicket-41413.herokuapp.com request_id=530b7d1f-0ae5-45a2-87a8-4bce19b0fbfd fwd="47.31.91.80" dyno=web.1 connect=0ms service=11ms status=304 bytes=152 protocol=https
2019-01-09T07:16:43.568099+00:00 heroku[router]: at=info method=GET path="/stylesheet/landing.css" host=protected-thicket-41413.herokuapp.com request_id=96f17009-0703-45c0-b1fa-35616e171ca7 fwd="47.31.91.80" dyno=web.1 connect=0ms service=7ms status=304 bytes=238 protocol=https
2019-01-09T07:16:44.039404+00:00 heroku[router]: at=info method=GET path="/stylesheet/header.css" host=protected-thicket-41413.herokuapp.com request_id=519c67e3-6783-41f0-a554-adc512565345 fwd="47.31.91.80" dyno=web.1 connect=1ms service=9ms status=304 bytes=238 protocol=https
2019-01-09T07:18:56.944801+00:00 heroku[router]: at=info method=POST path="/forgot" host=protected-thicket-41413.herokuapp.com request_id=23f37227-6fd4-41d9-bc01-b3e0f1f930e0 fwd="47.31.91.80" dyno=web.1 connect=0ms service=657ms status=500 bytes=404 protocol=https
2019-01-09T07:18:56.937571+00:00 app[web.1]: mail sent
2019-01-09T07:18:56.939762+00:00 app[web.1]: Error: Invalid login: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbtw
2019-01-09T07:18:56.939766+00:00 app[web.1]: 534-5.7.14 2yBkG8wNrX-0deRsQZCefLZkcgKOX2J9EkC3YiIn3zg5QS28Pb6GQwzlKdUFaFgjhIRenG
2019-01-09T07:18:56.939768+00:00 app[web.1]: 534-5.7.14 GBXlbwi6OF31IKHGLZAomjvke6iqK6WnGccuo-u5B3Hy1DIUUtyPK8qIE_8DOBLtQpVR0N
2019-01-09T07:18:56.939769+00:00 app[web.1]: 534-5.7.14 9BXeddk5ity2vY-atpRHYOBUCseTMmUZ_z7Yg0NyaAenn5tirCb5_01fhPiaFGvVzUHbUw
2019-01-09T07:18:56.939771+00:00 app[web.1]: 534-5.7.14 7U4U3IHQ5EMXNq18j2l3uR_jrIKW9cehq0FlMIdqG6_1siPXF_> Please log in via
2019-01-09T07:18:56.939774+00:00 app[web.1]: 534-5.7.14 your web browser and then try again.
2019-01-09T07:18:56.939776+00:00 app[web.1]: 534-5.7.14  Learn more at
2019-01-09T07:18:56.939778+00:00 app[web.1]: 534 5.7.14  https://support.google.com/mail/answer/78754 w22sm41868963qtw.71 - gsmtp
2019-01-09T07:18:56.939780+00:00 app[web.1]: at SMTPConnection._formatError (/app/node_modules/nodemailer/lib/smtp-connection/index.js:675:19)
2019-01-09T07:18:56.939782+00:00 app[web.1]: at SMTPConnection._actionAUTHComplete (/app/node_modules/nodemailer/lib/smtp-connection/index.js:1410:34)
2019-01-09T07:18:56.939784+00:00 app[web.1]: at SMTPConnection._responseActions.push.str (/app/node_modules/nodemailer/lib/smtp-connection/index.js:448:26)
2019-01-09T07:18:56.939786+00:00 app[web.1]: at SMTPConnection._processResponse (/app/node_modules/nodemailer/lib/smtp-connection/index.js:834:20)
2019-01-09T07:18:56.939787+00:00 app[web.1]: at SMTPConnection._onData (/app/node_modules/nodemailer/lib/smtp-connection/index.js:640:14)
2019-01-09T07:18:56.939789+00:00 app[web.1]: at TLSSocket._socket.on.chunk (/app/node_modules/nodemailer/lib/smtp-connection/index.js:592:47)
2019-01-09T07:18:56.939791+00:00 app[web.1]: at TLSSocket.emit (events.js:182:13)
2019-01-09T07:18:56.939792+00:00 app[web.1]: at addChunk (_stream_readable.js:283:12)
2019-01-09T07:18:56.939795+00:00 app[web.1]: at readableAddChunk (_stream_readable.js:264:11)
2019-01-09T07:18:56.939797+00:00 app[web.1]: at TLSSocket.Readable.push (_stream_readable.js:219:10)
2019-01-09T07:18:56.939799+00:00 app[web.1]: at TLSWrap.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
2019-01-09T07:26:40.970605+00:00 app[web.1]: mail sent
2019-01-09T07:26:40.972461+00:00 app[web.1]: Error: Invalid login: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbsu
2019-01-09T07:26:40.972468+00:00 app[web.1]: 534-5.7.14 1e5XxZtBWvhu0fLaUt8iPtFLnxOF6NinhygDqHwkMPgvt0OPgjnn5x0ddt0DDZcLNKpDg8
2019-01-09T07:26:40.972470+00:00 app[web.1]: 534-5.7.14 jx-VhbBC_txRxoTxdc5aCev81-7LGBbT5Z_7igTDV6Xw7i0MsVXv5_DemF53pDZLSuxYbU
2019-01-09T07:26:40.972472+00:00 app[web.1]: 534-5.7.14 zSFrfWaPHoNevvaN62d8pVX8fZldOTONA4TZqT4-RYjiWjpHypPRJqd3SZY39l6VmCLMY5
2019-01-09T07:26:40.972474+00:00 app[web.1]: 534-5.7.14 84Ris5HMBT1XBNmdeOaoN80wt_DeICmH3DR2yB5V6YzZlbdQLN> Please log in via
2019-01-09T07:26:40.972476+00:00 app[web.1]: 534-5.7.14 your web browser and then try again.
2019-01-09T07:26:40.972477+00:00 app[web.1]: 534-5.7.14  Learn more at
2019-01-09T07:26:40.972479+00:00 app[web.1]: 534 5.7.14  https://support.google.com/mail/answer/78754 u11sm37611486qtc.61 - gsmtp
2019-01-09T07:26:40.972481+00:00 app[web.1]: at SMTPConnection._formatError (/app/node_modules/nodemailer/lib/smtp-connection/index.js:675:19)
2019-01-09T07:26:40.972483+00:00 app[web.1]: at SMTPConnection._actionAUTHComplete (/app/node_modules/nodemailer/lib/smtp-connection/index.js:1410:34)
2019-01-09T07:26:40.972490+00:00 app[web.1]: at SMTPConnection._responseActions.push.str (/app/node_modules/nodemailer/lib/smtp-connection/index.js:448:26)
2019-01-09T07:26:40.972492+00:00 app[web.1]: at SMTPConnection._processResponse (/app/node_modules/nodemailer/lib/smtp-connection/index.js:834:20)
2019-01-09T07:26:40.972493+00:00 app[web.1]: at SMTPConnection._onData (/app/node_modules/nodemailer/lib/smtp-connection/index.js:640:14)
2019-01-09T07:26:40.972495+00:00 app[web.1]: at TLSSocket._socket.on.chunk (/app/node_modules/nodemailer/lib/smtp-connection/index.js:592:47)
2019-01-09T07:26:40.972497+00:00 app[web.1]: at TLSSocket.emit (events.js:182:13)
2019-01-09T07:26:40.972498+00:00 app[web.1]: at addChunk (_stream_readable.js:283:12)
2019-01-09T07:26:40.972501+00:00 app[web.1]: at readableAddChunk (_stream_readable.js:264:11)
2019-01-09T07:26:40.972503+00:00 app[web.1]: at TLSSocket.Readable.push (_stream_readable.js:219:10)
2019-01-09T07:26:40.972505+00:00 app[web.1]: at TLSWrap.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)

重置按钮代码

app.post('/forgot', function(req, res, next) {
  async.waterfall([
    function(done) {
      crypto.randomBytes(20, function(err, buf) {
        var token = buf.toString('hex');
        done(err, token);
      });
    },
    function(token, done) {
      User.findOne({ email: req.body.email }, function(err, user) {
        if (!user) {
          return res.redirect('/forgot');
        }

        user.resetPasswordToken = token;
        user.resetPasswordExpires = Date.now() + 3600000; // 1 hour

        user.save(function(err) {
          done(err, token, user);
        });
      });
    },
    function(token, user, done) {
      var smtpTransport = nodemailer.createTransport({
        service: 'Gmail', 
        auth: {
          user: 'dk1228095136@gmail.com',
          pass: '**************'
        }
      });
      var mailOptions = {
        to: user.email,
        from: 'dk1228095136@gmail.com',
        subject: 'promoter Password Reset',
        text: 'You are receiving this message because you (or someone else) have requested to reset your  password for your account.\n\n' +
          'Please click on the following link, or paste this into your browser to complete the process:\n\n' +
          'http://protected-thicket-41413.herokuapp.com/reset/' + token + '\n\n' +
          'If you did not request this, please ignore this email and your password will remain unchanged.\n'
      };
      smtpTransport.sendMail(mailOptions, function(err) {
        console.log('mail sent');
        done(err, 'done');
      });
    }
  ], function(err) {
    if (err) return next(err);
    res.redirect('/forgot');
  });
});

app.get('/reset/:token', function(req, res) {
  User.findOne({ resetPasswordToken: req.params.token, resetPasswordExpires: { $gt: Date.now() } }, function(err, user) {
    if (!user) {
      return res.redirect('/forgot');
    }
    res.render('reset', {token: req.params.token, currentUser:req.user, error:req.flash("error"),success:req.flash("success")});
  });
});

app.post('/reset/:token', function(req, res) {
  async.waterfall([
    function(done) {
      User.findOne({ resetPasswordToken: req.params.token, resetPasswordExpires: { $gt: Date.now() } }, function(err, user) {
        if (!user) {
          return res.redirect('back');
        }
        if(req.body.password === req.body.confirm) {
          user.setPassword(req.body.password, function(err) {
            user.resetPasswordToken = undefined;
            user.resetPasswordExpires = undefined;

            user.save(function(err) {
              req.logIn(user, function(err) {
                done(err, user);
              });
            });
          })
        } else {
            return res.redirect('back');
        }
      });
    },
    function(user, done) {
      var smtpTransport = nodemailer.createTransport({
        service: 'Gmail', 
        auth: {
          user: 'dk1228095136@gmail.com',
          pass: 'Dk9958039620'
        }
      });
      var mailOptions = {
        to: user.email,
        from: 'dk1228095136@mail.com',
        subject: 'Your password has been changed',
        text: 'Hello,\n\n' +
          'This is a confirmation that the password for your account ' + user.email + ' has just been changed.\n'
      };
      smtpTransport.sendMail(mailOptions, function(err) {
        console.log(err); 
        done(err);
      });
    }
  ], function(err) {
    res.redirect('/menu');
  });
});

0 个答案:

没有答案