2023-10-20 22:35:26 +08:00
|
|
|
// SPDX-FileCopyrightText: 2023 XWiki CryptPad Team <contact@cryptpad.org> and contributors
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
|
2017-11-22 01:22:01 +08:00
|
|
|
var Https = require('https');
|
2019-04-17 19:48:39 +08:00
|
|
|
var Config = require("../lib/load-config");
|
2019-04-08 22:31:36 +08:00
|
|
|
var Package = require("../package.json");
|
2017-11-22 01:22:01 +08:00
|
|
|
|
|
|
|
var body = JSON.stringify({
|
2020-03-04 22:59:17 +08:00
|
|
|
domain: Config.myDomain,
|
2019-04-09 21:10:15 +08:00
|
|
|
subdomain: Config.mySubdomain || null,
|
2017-11-22 01:22:01 +08:00
|
|
|
adminEmail: Config.adminEmail,
|
|
|
|
version: Package.version,
|
|
|
|
});
|
|
|
|
|
|
|
|
var options = {
|
|
|
|
host: 'accounts.cryptpad.fr',
|
|
|
|
path: '/api/getauthorized',
|
|
|
|
method: 'POST',
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
'Content-Length': Buffer.byteLength(body)
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-11-23 00:40:00 +08:00
|
|
|
Https.request(options, function (response) {
|
2017-11-22 01:22:01 +08:00
|
|
|
if (!('' + response.statusCode).match(/^2\d\d$/)) {
|
|
|
|
throw new Error('SERVER ERROR ' + response.statusCode);
|
|
|
|
}
|
|
|
|
var str = '';
|
|
|
|
response.on('data', function (chunk) {
|
|
|
|
str += chunk;
|
|
|
|
});
|
|
|
|
response.on('end', function () {
|
|
|
|
try {
|
|
|
|
var json = JSON.parse(str);
|
|
|
|
console.log(json);
|
|
|
|
} catch (e) {
|
|
|
|
throw new Error(e);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}).on('error', function (e) {
|
|
|
|
console.error(e);
|
|
|
|
}).end(body);
|