mirror of
https://github.com/cryptpad/cryptpad.git
synced 2026-09-14 11:05:41 +05:00
Merge branch 'soon' into staging
This commit is contained in:
commit
57cd25bc8f
@ -779,12 +779,14 @@ var commands = {
|
||||
|
||||
// addFirstAdmin is an anon_rpc command
|
||||
Admin.addFirstAdmin = function (Env, data, cb) {
|
||||
if (!Env.installToken) { return void cb('EINVAL'); }
|
||||
var token = data.token;
|
||||
if (!token || !data.edPublic) { return void cb('MISSING_ARGS'); }
|
||||
if (token.length !== 64 || data.edPublic.length !== 44) { return void cb('INVALID_ARGS'); }
|
||||
if (token !== Env.installToken) { return void cb('FORBIDDEN'); }
|
||||
if (Array.isArray(Env.admins) && Env.admins.length) { return void cb('EEXISTS'); }
|
||||
|
||||
var key = data.edPublic;
|
||||
if (token.length !== 64 || data.edPublic.length !== 44) { return void cb('INVALID_ARGS'); }
|
||||
|
||||
adminDecree(Env, null, function (err) {
|
||||
if (err) { return void cb(err); }
|
||||
|
||||
@ -167,6 +167,7 @@ module.exports.create = function (config) {
|
||||
|
||||
limits: {},
|
||||
admins: [],
|
||||
installToken: undefined,
|
||||
WARN: function (e, output) { // TODO deprecate this
|
||||
if (!Env.Log) { return; }
|
||||
if (e && output) {
|
||||
|
||||
@ -1,18 +1,12 @@
|
||||
var prompt = require('prompt-confirm');
|
||||
const p = new prompt('Are you sure? This will permanently delete all existing data on your instance.');
|
||||
|
||||
const nThen = require("nthen");
|
||||
const Fs = require("fs");
|
||||
const Path = require("path");
|
||||
|
||||
var config = require("../lib/load-config");
|
||||
var Hash = require('../www/common/common-hash');
|
||||
var Env = require("../lib/env").create(config);
|
||||
Env.Log = { error: console.log };
|
||||
|
||||
var keyOrDefaultString = function (key, def) {
|
||||
return Path.resolve(typeof(config[key]) === 'string'? config[key]: def);
|
||||
};
|
||||
var paths = Env.paths;
|
||||
p.ask(function (answer) {
|
||||
if (!answer) {
|
||||
@ -20,7 +14,6 @@ p.ask(function (answer) {
|
||||
return;
|
||||
}
|
||||
console.log('Deleting all data...');
|
||||
var n = nThen;
|
||||
Object.values(paths).forEach(function (path) {
|
||||
console.log(`Deleting ${path}`);
|
||||
Fs.rmSync(path, { recursive: true, force: true });
|
||||
|
||||
@ -2320,7 +2320,6 @@ define([
|
||||
localStorage.setItem(Constants.tokenKey, data[Constants.tokenKey]);
|
||||
}
|
||||
}
|
||||
|
||||
initFeedback(data.feedback);
|
||||
};
|
||||
|
||||
@ -2729,6 +2728,7 @@ define([
|
||||
if (data.error) { throw new Error(data.error); }
|
||||
if (data.state === 'ALREADY_INIT') {
|
||||
data = data.returned;
|
||||
initFeedback(data.feedback);
|
||||
}
|
||||
|
||||
if (data.loggedIn) {
|
||||
|
||||
@ -111,7 +111,7 @@ var init = function (client, cb) {
|
||||
if (data && data.state === "ALREADY_INIT") {
|
||||
debug('Store already exists!');
|
||||
self.store = data.returned;
|
||||
return void cb(data.returned);
|
||||
return void cb(data);
|
||||
}
|
||||
self.store = data;
|
||||
cb(data);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user