Delete 2FA data when archiving account

This commit is contained in:
yflory 2026-02-06 16:15:01 +01:00
parent 0cc63e0f2c
commit ca4fa68611
3 changed files with 22 additions and 0 deletions

View File

@ -14,6 +14,7 @@ const Meta = require("./metadata");
const Logger = require("./log");
const plugins = require("./plugin-manager");
const HK = require('./hk-util');
const MFA = require("./storage/mfa");
let SSOUtils = plugins.SSO && plugins.SSO.utils;
@ -212,6 +213,7 @@ COMMANDS.start = (edPublic, blockId, reason) => {
}
Log.info('MODERATION_ACCOUNT_BLOCK', safeKey, waitFor());
}));
MFA.delete(Env, blockId, waitFor());
if (!SSOUtils) { return; }
SSOUtils.deleteAccount(Env, blockId, waitFor((err) => {
if (err) {

View File

@ -444,6 +444,25 @@ app.use('/block/', function (req, res, next) {
w.abort();
next();
}
}).nThen(function (w) {
// Block is protected with 2FA or SSO, make sure it still exists
const url = req.url;
if (typeof(url) !== "string") { return; }
const s = url.split('/');
const id = s[2];
if (!(s[1]?.length === 2 && BlockStore.isValidKey(id))) { return; }
BlockStore.isAvailable(Env, id, w((err, val) => {
if (err) { return; }
if (val !== false) { return; }
// Block doesn't exist, send the placeholder
w.abort();
return BlockStore.readPlaceholder(Env, id, reason => {
res.status(404).json({
reason,
code: 404
});
});
}));
}).nThen(function (w) {
// We should only be able to reach this logic
// if we successfully loaded and parsed some JSON

View File

@ -1415,6 +1415,7 @@ define([
});
var getBlockId = (val) => {
if (val.length === 44) { return val; }
var url;
try {
url = new URL(val, ApiConfig.httpUnsafeOrigin);