fixed reset password
This commit is contained in:
parent
3f3ea25ac7
commit
0f1dcc89e0
|
@ -129,7 +129,6 @@ exports.validateResetToken = function(req, res) {
|
|||
exports.reset = function(req, res, next) {
|
||||
// Init Variables
|
||||
var passwordDetails = req.body;
|
||||
|
||||
async.waterfall([
|
||||
|
||||
function(done) {
|
||||
|
@ -147,31 +146,15 @@ exports.reset = function(req, res, next) {
|
|||
|
||||
user.save(function(err) {
|
||||
if (err) {
|
||||
return res.status(400).send({
|
||||
message: errorHandler.getErrorMessage(err)
|
||||
});
|
||||
} else {
|
||||
req.login(user, function(err) {
|
||||
if (err) {
|
||||
res.status(400).send(err);
|
||||
} else {
|
||||
// Return authenticated user
|
||||
res.json(user);
|
||||
|
||||
done(err, user);
|
||||
}
|
||||
});
|
||||
done(err, null)
|
||||
}
|
||||
done(null, user);
|
||||
});
|
||||
} else {
|
||||
return res.status(400).send({
|
||||
message: 'Passwords do not match'
|
||||
});
|
||||
done('Passwords do not match', null);
|
||||
}
|
||||
} else {
|
||||
return res.status(400).send({
|
||||
message: 'Password reset token is invalid or has expired.'
|
||||
});
|
||||
done('Password reset token is invalid or has expired.', null)
|
||||
}
|
||||
});
|
||||
},
|
||||
|
@ -193,11 +176,20 @@ exports.reset = function(req, res, next) {
|
|||
};
|
||||
|
||||
smtpTransport.sendMail(mailOptions, function(err) {
|
||||
done(err, 'done');
|
||||
done(err);
|
||||
});
|
||||
}
|
||||
], function(err) {
|
||||
if (err) return next(err);
|
||||
debugger;
|
||||
if (err) {
|
||||
res.status(500).send({
|
||||
message: err.message || err
|
||||
});
|
||||
}
|
||||
|
||||
return res.json({
|
||||
message: "Successfully changed your password!"
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
|
11
public/dist/application.js
vendored
11
public/dist/application.js
vendored
|
@ -1621,9 +1621,7 @@ angular.module('users').config(['$stateProvider',
|
|||
|
||||
var checkLoggedin = function($q, $timeout, $state, User, Auth) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
//console.log(Auth.ensureHasCurrentUser(User));
|
||||
|
||||
|
||||
if (Auth.currentUser && Auth.currentUser.email) {
|
||||
$timeout(deferred.resolve);
|
||||
}
|
||||
|
@ -1791,7 +1789,7 @@ angular.module('users').controller('AuthenticationController', ['$scope', '$loca
|
|||
|
||||
angular.module('users').controller('PasswordController', ['$scope', '$stateParams', '$state', 'User',
|
||||
function($scope, $stateParams, $state, User) {
|
||||
|
||||
|
||||
$scope.error = '';
|
||||
|
||||
// Submit forgotten password account id
|
||||
|
@ -1814,6 +1812,7 @@ angular.module('users').controller('PasswordController', ['$scope', '$stateParam
|
|||
User.resetPassword($scope.passwordDetails, $stateParams.token).then(
|
||||
function(response){
|
||||
// If successful show success message and clear form
|
||||
console.log(response);
|
||||
$scope.success = response.message;
|
||||
$scope.passwordDetails = null;
|
||||
|
||||
|
@ -2146,8 +2145,8 @@ angular.module('users').factory('User', ['$window', '$q', '$timeout', '$http', '
|
|||
resetPassword: function(passwordDetails, token) {
|
||||
|
||||
var deferred = $q.defer();
|
||||
$http.get('/auth/password/'+token, passwordDetails).then(function(response) {
|
||||
deferred.resolve();
|
||||
$http.post('/auth/reset/'+token, passwordDetails).then(function(response) {
|
||||
deferred.resolve(response);
|
||||
}, function(error) {
|
||||
deferred.reject(error.data.message || error.data);
|
||||
});
|
||||
|
|
4
public/dist/application.min.js
vendored
4
public/dist/application.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -6,9 +6,7 @@ angular.module('users').config(['$stateProvider',
|
|||
|
||||
var checkLoggedin = function($q, $timeout, $state, User, Auth) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
//console.log(Auth.ensureHasCurrentUser(User));
|
||||
|
||||
|
||||
if (Auth.currentUser && Auth.currentUser.email) {
|
||||
$timeout(deferred.resolve);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
angular.module('users').controller('PasswordController', ['$scope', '$stateParams', '$state', 'User',
|
||||
function($scope, $stateParams, $state, User) {
|
||||
|
||||
|
||||
$scope.error = '';
|
||||
|
||||
// Submit forgotten password account id
|
||||
|
@ -25,6 +25,7 @@ angular.module('users').controller('PasswordController', ['$scope', '$stateParam
|
|||
User.resetPassword($scope.passwordDetails, $stateParams.token).then(
|
||||
function(response){
|
||||
// If successful show success message and clear form
|
||||
console.log(response);
|
||||
$scope.success = response.message;
|
||||
$scope.passwordDetails = null;
|
||||
|
||||
|
|
|
@ -84,8 +84,8 @@ angular.module('users').factory('User', ['$window', '$q', '$timeout', '$http', '
|
|||
resetPassword: function(passwordDetails, token) {
|
||||
|
||||
var deferred = $q.defer();
|
||||
$http.get('/auth/password/'+token, passwordDetails).then(function(response) {
|
||||
deferred.resolve();
|
||||
$http.post('/auth/reset/'+token, passwordDetails).then(function(response) {
|
||||
deferred.resolve(response);
|
||||
}, function(error) {
|
||||
deferred.reject(error.data.message || error.data);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue