【发布时间】:2015-01-15 10:15:15
【问题描述】:
目前,我遇到了从 nodejs 获取消息的问题
在客户端(与nodejs分开),
'use strict';
angular.module('app').controller('RegisterCtrl', function ($scope, alert, $auth) {
$scope.submit = function () {
$auth.signup({
email: $scope.email,
password: $scope.password
})
.then(function (res) {
alert('success', 'Account Created!', 'Welcome, ' + res.data.user.email + '! Please email activate your account in the next several days.');
})
.catch(function (err) {
alert('warning', 'Unable to create account :(', err.message);
});
};
});
虽然,在 Nodejs 护照上我收到错误“电子邮件已被占用”,但它无法将此消息传递给客户端,客户端只收到 401(未经授权)。 我还安装了 connect-flash 并设置了
app.post('/auth/register', passport.authenticate('local-register', {
failureFlash : true // allow flash messages
}), function (req, res) {
emailVerification.send(req.user.email, res, req);
createSendToken(req.user, res);
});
但仍然没有运气。我怎样才能得到这个消息?谢谢
【问题讨论】:
标签: node.js passport.js