api: add user's monograph passwords key (#41)

This commit is contained in:
01zulfi
2025-08-18 11:45:42 +05:00
committed by GitHub
parent 8df70c81fc
commit 6d6342dbff
6 changed files with 52 additions and 7 deletions
+13 -2
View File
@@ -128,6 +128,7 @@ namespace Notesnook.API.Services
MFA = user.MFA,
PhoneNumber = user.PhoneNumber,
AttachmentsKey = userSettings.AttachmentsKey,
MonographPasswordsKey = userSettings.MonographPasswordsKey,
Salt = userSettings.Salt,
Subscription = subscription,
Success = true,
@@ -135,10 +136,19 @@ namespace Notesnook.API.Services
};
}
public async Task SetUserAttachmentsKeyAsync(string userId, IEncrypted key)
public async Task SetUserKeysAsync(string userId, UserKeys keys)
{
var userSettings = await Repositories.UsersSettings.FindOneAsync((u) => u.UserId == userId) ?? throw new Exception("User not found.");
userSettings.AttachmentsKey = (EncryptedData)key;
if (keys.AttachmentsKey != null)
{
userSettings.AttachmentsKey = keys.AttachmentsKey;
}
if (keys.MonographPasswordsKey != null)
{
userSettings.MonographPasswordsKey = keys.MonographPasswordsKey;
}
await Repositories.UsersSettings.UpdateAsync(userSettings.Id, userSettings);
}
@@ -226,6 +236,7 @@ namespace Notesnook.API.Services
var userSettings = await Repositories.UsersSettings.FindOneAsync((s) => s.UserId == userId);
userSettings.AttachmentsKey = null;
userSettings.MonographPasswordsKey = null;
userSettings.VaultKey = null;
userSettings.LastSynced = 0;