mirror of https://github.com/xwiki-labs/cryptpad
add some logging and avoid some errors
This commit is contained in:
parent
b1e69e5c91
commit
15a8284a30
|
@ -112,7 +112,7 @@ var validateAncestorProof = function (Env, proof, _cb) {
|
||||||
return void cb("E_MISSING_ANCESTOR");
|
return void cb("E_MISSING_ANCESTOR");
|
||||||
}));
|
}));
|
||||||
}).nThen(function () {
|
}).nThen(function () {
|
||||||
cb(void 0, valid);
|
cb(void 0, pub);
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return void cb(err);
|
return void cb(err);
|
||||||
|
@ -126,6 +126,7 @@ Block.writeLoginBlock = function (Env, safeKey, msg, _cb) { // FIXME BLOCKS
|
||||||
var signature = msg[1];
|
var signature = msg[1];
|
||||||
var block = msg[2];
|
var block = msg[2];
|
||||||
var registrationProof = msg[3];
|
var registrationProof = msg[3];
|
||||||
|
var previousKey;
|
||||||
|
|
||||||
var validatedBlock, parsed, path;
|
var validatedBlock, parsed, path;
|
||||||
nThen(function (w) {
|
nThen(function (w) {
|
||||||
|
@ -136,13 +137,15 @@ Block.writeLoginBlock = function (Env, safeKey, msg, _cb) { // FIXME BLOCKS
|
||||||
w.abort();
|
w.abort();
|
||||||
return cb("E_RESTRICTED");
|
return cb("E_RESTRICTED");
|
||||||
}
|
}
|
||||||
validateAncestorProof(Env, registrationProof, w(function (err, validated) {
|
validateAncestorProof(Env, registrationProof, w(function (err, provenKey) {
|
||||||
if (err || !validated) { // double check that it was validated
|
if (err || !provenKey) { // double check that a key was validated
|
||||||
w.abort();
|
w.abort();
|
||||||
// XXX Log
|
Env.Log.warn('BLOCK_REJECTED_INVALID_ANCESTOR', {
|
||||||
return void cb("E_RESTRICTED"); // XXX restricted-registration we can provide more descriptive errors if we check that the client will understand them
|
error: err,
|
||||||
|
});
|
||||||
|
return void cb("E_RESTRICTED");
|
||||||
}
|
}
|
||||||
// else fall through to the next block
|
previousKey = provenKey;
|
||||||
}));
|
}));
|
||||||
}).nThen(function (w) {
|
}).nThen(function (w) {
|
||||||
validateLoginBlock(Env, publicKey, signature, block, w(function (e, _validatedBlock) {
|
validateLoginBlock(Env, publicKey, signature, block, w(function (e, _validatedBlock) {
|
||||||
|
@ -183,7 +186,12 @@ Block.writeLoginBlock = function (Env, safeKey, msg, _cb) { // FIXME BLOCKS
|
||||||
// actually write the block
|
// actually write the block
|
||||||
Fs.writeFile(path, Buffer.from(validatedBlock), { encoding: "binary", }, function (err) {
|
Fs.writeFile(path, Buffer.from(validatedBlock), { encoding: "binary", }, function (err) {
|
||||||
if (err) { return void cb(err); }
|
if (err) { return void cb(err); }
|
||||||
// XXX log the safeKey to map publicKey <=> block
|
Env.Log.info('BLOCK_WRITE_BY_OWNER', {
|
||||||
|
safeKey: safeKey,
|
||||||
|
blockId: publicKey,
|
||||||
|
isChange: Boolean(registrationProof),
|
||||||
|
previousKey: previousKey,
|
||||||
|
});
|
||||||
cb();
|
cb();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -276,7 +276,7 @@ var serveConfig = makeRouteCache(function (host) {
|
||||||
defaultStorageLimit: Env.defaultStorageLimit,
|
defaultStorageLimit: Env.defaultStorageLimit,
|
||||||
maxUploadSize: Env.maxUploadSize,
|
maxUploadSize: Env.maxUploadSize,
|
||||||
premiumUploadSize: Env.premiumUploadSize,
|
premiumUploadSize: Env.premiumUploadSize,
|
||||||
restrictRegistration: Env.restrictRegistration, // XXX restricted-registration
|
restrictRegistration: Env.restrictRegistration,
|
||||||
}, null, '\t'),
|
}, null, '\t'),
|
||||||
'obj.httpSafeOrigin = ' + (function () {
|
'obj.httpSafeOrigin = ' + (function () {
|
||||||
if (config.httpSafeOrigin) { return '"' + config.httpSafeOrigin + '"'; }
|
if (config.httpSafeOrigin) { return '"' + config.httpSafeOrigin + '"'; }
|
||||||
|
|
|
@ -96,7 +96,7 @@ define([
|
||||||
// return an array with the sig and the pubkey
|
// return an array with the sig and the pubkey
|
||||||
return JSON.stringify([u8_pub, u8_sig].map(Nacl.util.encodeBase64));
|
return JSON.stringify([u8_pub, u8_sig].map(Nacl.util.encodeBase64));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw err; // XXX restricted-registration
|
return void console.error(err);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue