mirror of
https://github.com/streetwriters/notesnook-sync-server.git
synced 2026-10-12 06:57:06 +02:00
sync: fix vault key getting reset on sync
This commit is contained in:
1 parent
b8835923c5
commit
e7350e2c49
2 files changed
+18
-1
No files matched your search
@@ -305,7 +305,14 @@ namespace Notesnook.API.Hubs
|
|||||||
GlobalSync.StartPush(userId, Context.ConnectionId);
|
GlobalSync.StartPush(userId, Context.ConnectionId);
|
||||||
|
|
||||||
|
|
||||||
if (userSettings.VaultKey != null && syncMetadata.VaultKey != null && !userSettings.VaultKey.Equals(syncMetadata.VaultKey) || (userSettings.VaultKey == null && syncMetadata.VaultKey != null))
|
if (
|
||||||
|
(userSettings.VaultKey != null &&
|
||||||
|
syncMetadata.VaultKey != null &&
|
||||||
|
!userSettings.VaultKey.Equals(syncMetadata.VaultKey) &&
|
||||||
|
!syncMetadata.VaultKey.IsEmpty()) ||
|
||||||
|
(userSettings.VaultKey == null &&
|
||||||
|
syncMetadata.VaultKey != null &&
|
||||||
|
!syncMetadata.VaultKey.IsEmpty()))
|
||||||
{
|
{
|
||||||
userSettings.VaultKey = syncMetadata.VaultKey;
|
userSettings.VaultKey = syncMetadata.VaultKey;
|
||||||
await Repositories.UsersSettings.UpsertAsync(userSettings, (u) => u.UserId == userId);
|
await Repositories.UsersSettings.UpsertAsync(userSettings, (u) => u.UserId == userId);
|
||||||
|
|||||||
@@ -25,8 +25,10 @@ using System.Text.Json.Serialization;
|
|||||||
|
|
||||||
namespace Notesnook.API.Models
|
namespace Notesnook.API.Models
|
||||||
{
|
{
|
||||||
|
[MessagePack.MessagePackObject]
|
||||||
public class EncryptedData : IEncrypted
|
public class EncryptedData : IEncrypted
|
||||||
{
|
{
|
||||||
|
[MessagePack.Key("iv")]
|
||||||
[JsonPropertyName("iv")]
|
[JsonPropertyName("iv")]
|
||||||
[BsonElement("iv")]
|
[BsonElement("iv")]
|
||||||
[DataMember(Name = "iv")]
|
[DataMember(Name = "iv")]
|
||||||
@@ -35,6 +37,7 @@ namespace Notesnook.API.Models
|
|||||||
get; set;
|
get; set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[MessagePack.Key("cipher")]
|
||||||
[JsonPropertyName("cipher")]
|
[JsonPropertyName("cipher")]
|
||||||
[BsonElement("cipher")]
|
[BsonElement("cipher")]
|
||||||
[DataMember(Name = "cipher")]
|
[DataMember(Name = "cipher")]
|
||||||
@@ -43,11 +46,13 @@ namespace Notesnook.API.Models
|
|||||||
get; set;
|
get; set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[MessagePack.Key("length")]
|
||||||
[JsonPropertyName("length")]
|
[JsonPropertyName("length")]
|
||||||
[BsonElement("length")]
|
[BsonElement("length")]
|
||||||
[DataMember(Name = "length")]
|
[DataMember(Name = "length")]
|
||||||
public long Length { get; set; }
|
public long Length { get; set; }
|
||||||
|
|
||||||
|
[MessagePack.Key("salt")]
|
||||||
[JsonPropertyName("salt")]
|
[JsonPropertyName("salt")]
|
||||||
[BsonElement("salt")]
|
[BsonElement("salt")]
|
||||||
[DataMember(Name = "salt")]
|
[DataMember(Name = "salt")]
|
||||||
@@ -61,5 +66,10 @@ namespace Notesnook.API.Models
|
|||||||
}
|
}
|
||||||
return base.Equals(obj);
|
return base.Equals(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsEmpty()
|
||||||
|
{
|
||||||
|
return this.Cipher == null && this.IV == null && this.Length == 0 && this.Salt == null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user