Exclude user's own password from /me endpoint (#20735)

pull/20747/head
Kevin Aleman 4 years ago committed by GitHub
parent dce9364be9
commit 4ec6e41c83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      app/api/server/v1/misc.js
  2. 1
      tests/end-to-end/api/00-miscellaneous.js

@ -49,7 +49,8 @@ API.v1.addRoute('info', { authRequired: false }, {
API.v1.addRoute('me', { authRequired: true }, {
get() {
return API.v1.success(this.getUserInfo(Users.findOneById(this.userId, { fields: getDefaultUserFields() })));
const { 'services.password.bcrypt': password, ...fields } = getDefaultUserFields();
return API.v1.success(this.getUserInfo(Users.findOneById(this.userId, { fields })));
},
});

@ -155,6 +155,7 @@ describe('miscellaneous', function() {
expect(res.body).to.have.nested.property('emails[0].address', adminEmail);
expect(res.body).to.have.nested.property('settings.preferences').and.to.be.an('object');
expect(res.body.settings.preferences).to.have.all.keys(allUserPreferencesKeys);
expect(res.body.services).to.not.have.property('password');
})
.end(done);
});

Loading…
Cancel
Save