0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Removed unused password logic from Member model

no-issue
This commit is contained in:
Fabien O'Carroll 2019-09-18 16:08:58 +08:00
parent aa7f9ddbeb
commit e078cb5612

View file

@ -1,33 +1,7 @@
const ghostBookshelf = require('./base');
const security = require('../lib/security');
const Member = ghostBookshelf.Model.extend({
tableName: 'members',
onSaving() {
ghostBookshelf.Model.prototype.onSaving.apply(this, arguments);
if (this.hasChanged('password')) {
return security.password.hash(String(this.get('password')))
.then((hash) => {
this.set('password', hash);
});
}
},
comparePassword(rawPassword) {
return security.password.compare(rawPassword, this.get('password'));
},
toJSON(unfilteredOptions) {
var options = Member.filterOptions(unfilteredOptions, 'toJSON'),
attrs = ghostBookshelf.Model.prototype.toJSON.call(this, options);
// remove password hash and tokens for security reasons
delete attrs.password;
return attrs;
}
tableName: 'members'
});
const Members = ghostBookshelf.Collection.extend({