Run cleanup
This commit is contained in:
@@ -1412,7 +1412,9 @@ router.post(
|
|||||||
hostData.authType === "credential" ? hostData.credentialId : null,
|
hostData.authType === "credential" ? hostData.credentialId : null,
|
||||||
key: hostData.authType === "key" ? hostData.key : null,
|
key: hostData.authType === "key" ? hostData.key : null,
|
||||||
key_password:
|
key_password:
|
||||||
hostData.authType === "key" ? (hostData.keyPassword || hostData.key_password || null) : null,
|
hostData.authType === "key"
|
||||||
|
? hostData.keyPassword || hostData.key_password || null
|
||||||
|
: null,
|
||||||
keyType:
|
keyType:
|
||||||
hostData.authType === "key" ? hostData.keyType || "auto" : null,
|
hostData.authType === "key" ? hostData.keyType || "auto" : null,
|
||||||
pin: hostData.pin || false,
|
pin: hostData.pin || false,
|
||||||
|
|||||||
@@ -893,8 +893,7 @@ router.post("/login", async (req, res) => {
|
|||||||
if (kekSalt.length === 0) {
|
if (kekSalt.length === 0) {
|
||||||
await authManager.registerUser(userRecord.id, password);
|
await authManager.registerUser(userRecord.id, password);
|
||||||
}
|
}
|
||||||
} catch (setupError) {
|
} catch (setupError) {}
|
||||||
}
|
|
||||||
|
|
||||||
const dataUnlocked = await authManager.authenticateUser(
|
const dataUnlocked = await authManager.authenticateUser(
|
||||||
userRecord.id,
|
userRecord.id,
|
||||||
@@ -1317,7 +1316,7 @@ router.post("/complete-reset", async (req, res) => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const hasActiveSession = authManager.isUserUnlocked(userId);
|
const hasActiveSession = authManager.isUserUnlocked(userId);
|
||||||
|
|
||||||
if (hasActiveSession) {
|
if (hasActiveSession) {
|
||||||
const success = await authManager.resetUserPasswordWithPreservedDEK(
|
const success = await authManager.resetUserPasswordWithPreservedDEK(
|
||||||
userId,
|
userId,
|
||||||
|
|||||||
@@ -263,13 +263,15 @@ class UserCrypto {
|
|||||||
|
|
||||||
const newKekSalt = await this.generateKEKSalt();
|
const newKekSalt = await this.generateKEKSalt();
|
||||||
const newKEK = this.deriveKEK(newPassword, newKekSalt);
|
const newKEK = this.deriveKEK(newPassword, newKekSalt);
|
||||||
|
|
||||||
const newEncryptedDEK = this.encryptDEK(DEK, newKEK);
|
const newEncryptedDEK = this.encryptDEK(DEK, newKEK);
|
||||||
|
|
||||||
await this.storeKEKSalt(userId, newKekSalt);
|
await this.storeKEKSalt(userId, newKekSalt);
|
||||||
await this.storeEncryptedDEK(userId, newEncryptedDEK);
|
await this.storeEncryptedDEK(userId, newEncryptedDEK);
|
||||||
|
|
||||||
const { saveMemoryDatabaseToFile } = await import("../database/db/index.js");
|
const { saveMemoryDatabaseToFile } = await import(
|
||||||
|
"../database/db/index.js"
|
||||||
|
);
|
||||||
await saveMemoryDatabaseToFile();
|
await saveMemoryDatabaseToFile();
|
||||||
|
|
||||||
oldKEK.fill(0);
|
oldKEK.fill(0);
|
||||||
@@ -282,7 +284,7 @@ class UserCrypto {
|
|||||||
if (oldSession) {
|
if (oldSession) {
|
||||||
oldSession.dataKey.fill(0);
|
oldSession.dataKey.fill(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.userSessions.set(userId, {
|
this.userSessions.set(userId, {
|
||||||
dataKey: dekCopy,
|
dataKey: dekCopy,
|
||||||
lastActivity: now,
|
lastActivity: now,
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user