From cb11abef41002c57623078883a3bf719680d10e4 Mon Sep 17 00:00:00 2001 From: Herbert Poul Date: Mon, 16 Aug 2021 15:32:14 +0200 Subject: [PATCH] make credentials changable. --- CHANGELOG.md | 3 ++- lib/src/kdbx_file.dart | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ffa2d38..8e2b039 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@ -## 2.3.0 +## 2.3.0 (unreleased) - Mark objects only as clean when saving was successful. - Only mark objects as clean if they have not been modified since we started saving. +- Make credentials changeable. ## 2.2.0 diff --git a/lib/src/kdbx_file.dart b/lib/src/kdbx_file.dart index f987d1b..d413834 100644 --- a/lib/src/kdbx_file.dart +++ b/lib/src/kdbx_file.dart @@ -22,7 +22,12 @@ typedef FileSaveCallback = Future Function(Uint8List bytes); class KdbxFile { KdbxFile( - this.ctx, this.kdbxFormat, this.credentials, this.header, this.body) { + this.ctx, + this.kdbxFormat, + this._credentials, + this.header, + this.body, + ) { for (final obj in _allObjects) { obj.file = this; } @@ -41,7 +46,12 @@ class KdbxFile { final KdbxFormat kdbxFormat; final KdbxReadWriteContext ctx; - final Credentials credentials; + Credentials get credentials => _credentials; + set credentials(Credentials credentials) { + body.meta.modify(() => _credentials = credentials); + } + + Credentials _credentials; final KdbxHeader header; final KdbxBody body; final Set dirtyObjects = {};