sahat/megaboilerplate

Angular Password reset is not working

TheNuttyMaker opened this issue · 0 comments

The resetPassword function on the account service tries to call '/reset', but on the server the only valid route is '/reset/:token' Below is the actual code
angular.module('MyApp') .factory('Account', function($http) { return { updateProfile: function(data) { return $http.put('/account', data); }, changePassword: function(data) { return $http.put('/account', data); }, deleteAccount: function() { return $http.delete('/account'); }, forgotPassword: function(data) { return $http.post('/forgot', data); }, resetPassword: function(data) { return $http.post('/reset', data); } }; });

Solution
For new user just change the /reset path to $location.path() where $location.path() will return /reset/resetPasswordToken. Below is the code.
angular.module('MyApp') .factory('Account', ["$http", "$location", function($http, $location) { return { updateProfile: function(data) { return $http.put('/account', data); }, changePassword: function(data) { return $http.put('/account', data); }, deleteAccount: function() { return $http.delete('/account'); }, forgotPassword: function(data) { return $http.post('/forgot', data); }, resetPassword: function(data) { return $http.post($location.path(), data); } }; }]);