prevent user keys override, will add this later with password change
This commit is contained in:
parent
cd581593bb
commit
bcd0e2c0ec
1 changed files with 14 additions and 2 deletions
|
|
@ -488,8 +488,20 @@ public static async Task Auth(HttpContext context, Func<Task> next, IQueryCollec
|
||||||
body,
|
body,
|
||||||
AppJsonSerializerContext.Default.Universal2String
|
AppJsonSerializerContext.Default.Universal2String
|
||||||
);
|
);
|
||||||
//string publicKey = serializedBody.string1;
|
string existingRaw = await Utils.GetUserKeys(id);
|
||||||
//string privateEncryptedKey = serializedBody.string2;
|
if (!string.IsNullOrWhiteSpace(existingRaw))
|
||||||
|
{
|
||||||
|
Universal2String existing = JsonSerializer.Deserialize(
|
||||||
|
existingRaw,
|
||||||
|
AppJsonSerializerContext.Default.Universal2String
|
||||||
|
);
|
||||||
|
string existingPub = existing.string2?.Trim() ?? "";
|
||||||
|
string newPub = serializedBody.string2?.Trim() ?? "";
|
||||||
|
if (!string.IsNullOrEmpty(existingPub) && !string.IsNullOrEmpty(newPub) && existingPub != newPub)
|
||||||
|
{
|
||||||
|
return "error:keys.public.mismatch";
|
||||||
|
}
|
||||||
|
}
|
||||||
await Utils.UpdateUserKeys(id, body);
|
await Utils.UpdateUserKeys(id, body);
|
||||||
return "success:keys.updated";
|
return "success:keys.updated";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue