diff options
Diffstat (limited to 'src/Converter/PasswordConverter.js')
-rw-r--r-- | src/Converter/PasswordConverter.js | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/Converter/PasswordConverter.js b/src/Converter/PasswordConverter.js index 2874ebf..13e16e5 100644 --- a/src/Converter/PasswordConverter.js +++ b/src/Converter/PasswordConverter.js @@ -8,8 +8,9 @@ export default class PasswordConverter extends AbstractConverter { */ constructor(api) { super(api, 'password'); - /** @type CustomFieldConverter **/ + /** @type {CustomFieldConverter} **/ this._customFieldConverter = this._api.getInstance('converter.field'); + this._hashService = /** @type {HashService} **/ this._api.getInstance('service.hash'); } /** @@ -37,4 +38,18 @@ export default class PasswordConverter extends AbstractConverter { return this._api.getClass(`model.${this._type}`, clone, this._api); } + + /** + * + * @param {(Password|AbstractRevisionModel)} model + * @returns {Promise<void>} + */ + async toObject(model) { + let data = super.toObject(model); + + data.customFields = this._customFieldConverter.toJSON(model.getCustomFields()); + data.hash = await this._hashService.getHash(model.getPassword(), this._hashService.HASH_SHA_1); + + return data; + } }
\ No newline at end of file |