tinker tinker - 1 year ago 103
AngularJS Question

What is the correct way to change password in Angular-Strongloop app?

I have looked through docs, SO and the interwebs, unable to find an example that shows how the password for a User can be changed with a Strongloop backend and an app using the AngularJS API generated by slc. Highly appreciate pointers in the right direction.

I'm not looking for the reset password which is the case the password is forgotten.
I'm looking for a legitimate way to change where the old pass as well as new pass needs to be provided and the old pass will be validated before the new pass is set.

Answer Source

There is no need to log the user in again, simply run the hasPassword method on the User to compare the passwords and if true, update the attribute

something like this... if(user.hasPassword(req.body.oldPassword)) { user.updateAttribute('password', req.body.password .... }