diff --git a/Notesnook.API/Controllers/UsersController.cs b/Notesnook.API/Controllers/UsersController.cs
index 7a3ea74..d79ee11 100644
--- a/Notesnook.API/Controllers/UsersController.cs
+++ b/Notesnook.API/Controllers/UsersController.cs
@@ -74,8 +74,12 @@ namespace Notesnook.API.Controllers
var userId = User.FindFirstValue("sub");
try
{
- if (user.AttachmentsKey != null)
- await UserService.SetUserAttachmentsKeyAsync(userId, user.AttachmentsKey);
+ var keys = new UserKeys
+ {
+ AttachmentsKey = user.AttachmentsKey,
+ MonographPasswordsKey = user.MonographPasswordsKey
+ };
+ await UserService.SetUserKeysAsync(userId, keys);
return Ok();
}
catch (Exception ex)
diff --git a/Notesnook.API/Interfaces/IUserService.cs b/Notesnook.API/Interfaces/IUserService.cs
index 8054c37..45137c4 100644
--- a/Notesnook.API/Interfaces/IUserService.cs
+++ b/Notesnook.API/Interfaces/IUserService.cs
@@ -17,10 +17,9 @@ You should have received a copy of the Affero GNU General Public License
along with this program. If not, see .
*/
-using System.Threading;
using System.Threading.Tasks;
+using Notesnook.API.Models;
using Notesnook.API.Models.Responses;
-using Streetwriters.Common.Interfaces;
namespace Notesnook.API.Interfaces
{
@@ -31,6 +30,6 @@ namespace Notesnook.API.Interfaces
Task DeleteUserAsync(string userId, string jti, string password);
Task ResetUserAsync(string userId, bool removeAttachments);
Task GetUserAsync(string userId);
- Task SetUserAttachmentsKeyAsync(string userId, IEncrypted key);
+ Task SetUserKeysAsync(string userId, UserKeys keys);
}
}
\ No newline at end of file
diff --git a/Notesnook.API/Models/Responses/UserResponse.cs b/Notesnook.API/Models/Responses/UserResponse.cs
index 65fba30..b8b1014 100644
--- a/Notesnook.API/Models/Responses/UserResponse.cs
+++ b/Notesnook.API/Models/Responses/UserResponse.cs
@@ -12,6 +12,9 @@ namespace Notesnook.API.Models.Responses
[JsonPropertyName("attachmentsKey")]
public EncryptedData AttachmentsKey { get; set; }
+ [JsonPropertyName("monographPasswordsKey")]
+ public EncryptedData MonographPasswordsKey { get; set; }
+
[JsonPropertyName("subscription")]
public ISubscription Subscription { get; set; }
diff --git a/Notesnook.API/Models/UserKeys.cs b/Notesnook.API/Models/UserKeys.cs
new file mode 100644
index 0000000..f77378d
--- /dev/null
+++ b/Notesnook.API/Models/UserKeys.cs
@@ -0,0 +1,27 @@
+/*
+This file is part of the Notesnook Sync Server project (https://notesnook.com/)
+
+Copyright (C) 2023 Streetwriters (Private) Limited
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the Affero GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+Affero GNU General Public License for more details.
+
+You should have received a copy of the Affero GNU General Public License
+along with this program. If not, see .
+*/
+
+namespace Notesnook.API.Models
+{
+ public class UserKeys
+ {
+ public EncryptedData AttachmentsKey { get; set; }
+ public EncryptedData MonographPasswordsKey { get; set; }
+ }
+}
diff --git a/Notesnook.API/Models/UserSettings.cs b/Notesnook.API/Models/UserSettings.cs
index d98460a..fc9d4e0 100644
--- a/Notesnook.API/Models/UserSettings.cs
+++ b/Notesnook.API/Models/UserSettings.cs
@@ -34,6 +34,7 @@ namespace Notesnook.API.Models
public string Salt { get; set; }
public EncryptedData VaultKey { get; set; }
public EncryptedData AttachmentsKey { get; set; }
+ public EncryptedData MonographPasswordsKey { get; set; }
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
diff --git a/Notesnook.API/Services/UserService.cs b/Notesnook.API/Services/UserService.cs
index 88620d8..857d089 100644
--- a/Notesnook.API/Services/UserService.cs
+++ b/Notesnook.API/Services/UserService.cs
@@ -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;