Changeset 0.17.1 (#76)
This commit is contained in:
@@ -266,18 +266,18 @@ func hashToken(token string) string {
|
||||
//
|
||||
// Does NOT evict from UEK cache or write audit logs — callers handle that.
|
||||
func DestroyVaultDB(ctx context.Context, userID string) (providersDeleted int64) {
|
||||
_, err := database.DB.ExecContext(ctx, `
|
||||
_, err := database.DB.ExecContext(ctx, database.Q(`
|
||||
UPDATE users
|
||||
SET encrypted_uek = NULL, uek_salt = NULL, uek_nonce = NULL, vault_set = false
|
||||
WHERE id = $1
|
||||
`, userID)
|
||||
`), userID)
|
||||
if err != nil {
|
||||
log.Printf("⚠ DestroyVaultDB: failed to clear vault columns for user %s: %v", userID, err)
|
||||
}
|
||||
|
||||
result, err := database.DB.ExecContext(ctx, `
|
||||
result, err := database.DB.ExecContext(ctx, database.Q(`
|
||||
DELETE FROM provider_configs WHERE scope = 'personal' AND owner_id = $1
|
||||
`, userID)
|
||||
`), userID)
|
||||
if err != nil {
|
||||
log.Printf("⚠ DestroyVaultDB: failed to delete personal providers for user %s: %v", userID, err)
|
||||
return 0
|
||||
@@ -298,10 +298,10 @@ func ProbeAndRepairVault(ctx context.Context, userID, password string) {
|
||||
var vaultSet bool
|
||||
var encryptedUEK, salt, nonce []byte
|
||||
|
||||
err := database.DB.QueryRowContext(ctx, `
|
||||
err := database.DB.QueryRowContext(ctx, database.Q(`
|
||||
SELECT vault_set, encrypted_uek, uek_salt, uek_nonce
|
||||
FROM users WHERE id = $1
|
||||
`, userID).Scan(&vaultSet, &encryptedUEK, &salt, &nonce)
|
||||
`), userID).Scan(&vaultSet, &encryptedUEK, &salt, &nonce)
|
||||
if err != nil || !vaultSet {
|
||||
return // no vault to probe
|
||||
}
|
||||
@@ -344,11 +344,11 @@ func (h *AuthHandler) initVault(ctx context.Context, userID, password string) er
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = database.DB.ExecContext(ctx, `
|
||||
_, err = database.DB.ExecContext(ctx, database.Q(`
|
||||
UPDATE users
|
||||
SET encrypted_uek = $1, uek_salt = $2, uek_nonce = $3, vault_set = true
|
||||
WHERE id = $4
|
||||
`, encryptedUEK, salt, nonce, userID)
|
||||
`), encryptedUEK, salt, nonce, userID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -369,10 +369,10 @@ func (h *AuthHandler) unlockVault(ctx context.Context, user *models.User, passwo
|
||||
var vaultSet bool
|
||||
var encryptedUEK, salt, nonce []byte
|
||||
|
||||
err := database.DB.QueryRowContext(ctx, `
|
||||
err := database.DB.QueryRowContext(ctx, database.Q(`
|
||||
SELECT vault_set, encrypted_uek, uek_salt, uek_nonce
|
||||
FROM users WHERE id = $1
|
||||
`, user.ID).Scan(&vaultSet, &encryptedUEK, &salt, &nonce)
|
||||
`), user.ID).Scan(&vaultSet, &encryptedUEK, &salt, &nonce)
|
||||
if err != nil {
|
||||
log.Printf("⚠ Vault query failed for user %s: %v", user.ID, err)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user