update-password.js 591 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. module.exports = {
  2. friendlyName: 'Update password',
  3. description: 'Update the password for the logged-in user.',
  4. inputs: {
  5. password: {
  6. description: 'The new, unencrypted password.',
  7. example: 'abc123v2',
  8. required: true
  9. }
  10. },
  11. fn: async function (inputs, exits) {
  12. // Hash the new password.
  13. var hashed = await sails.helpers.passwords.hashPassword(inputs.password);
  14. // Update the record for the logged-in user.
  15. await User.update({ id: this.req.me.id })
  16. .set({
  17. password: hashed
  18. });
  19. return exits.success();
  20. }
  21. };