HabitRPG/habitrpg — pull request #3925 by ebiagogo (2014-08-26 13:18:01+00:00)
Title: Fixed bug #3007 where using wrong "old password" when changing password ...

...results in "Password changed succesfully" message even though password change fails.

The root of this issue was in public/js/app.js, specifically myHttpInterceptor wasn't rejecting the promise correctly when there's an error. The fix was pretty simple but it had implications in other parts of the UI because there were several $http.post calls that had ".error(function(..." doing the wrong thing (handling the data instead of data.err). I updated that code as well.

Related to this problem, the check for '400 range?' (also in public/js/app.js) is incorrect. It's checking if response < 500 instead of response.status. I changed it to check "response.status". And instead of rejecting the promise for everything (because I wasn't sure if that's correct) I changed the code to do it if the response.status is 401 (since this is the exact response returned from the controller in case of error). I figured the more conservative approach was the safer one.