mirror of https://github.com/xwiki-labs/cryptpad
Fix issues with templates in polls #375
This commit is contained in:
parent
de3bb5cdcf
commit
3be85b155d
|
@ -719,7 +719,8 @@ define([
|
|||
}
|
||||
}
|
||||
sframeChan.query('Q_SAVE_AS_TEMPLATE', {
|
||||
toSave: toSave
|
||||
toSave: toSave,
|
||||
title: title
|
||||
}, function () {
|
||||
UI.alert(Messages.templateSaved);
|
||||
Feedback.send('TEMPLATE_CREATED');
|
||||
|
|
|
@ -28,9 +28,9 @@ define([
|
|||
}
|
||||
};
|
||||
|
||||
var makeConfig = function (hash, password) {
|
||||
var makeConfig = function (hash, opt) {
|
||||
// We can't use cryptget with a file or a user so we can use 'pad' as hash type
|
||||
var secret = Hash.getSecrets('pad', hash, password);
|
||||
var secret = Hash.getSecrets('pad', hash, opt.password);
|
||||
if (!secret.keys) { secret.keys = secret.key; } // support old hashses
|
||||
var config = {
|
||||
websocketURL: NetConfig.getWebsocketURL(),
|
||||
|
@ -38,6 +38,7 @@ define([
|
|||
validateKey: secret.keys.validateKey || undefined,
|
||||
crypto: Crypto.createEncryptor(secret.keys),
|
||||
logLevel: 0,
|
||||
initialState: opt.initialState
|
||||
};
|
||||
return config;
|
||||
};
|
||||
|
@ -57,7 +58,7 @@ define([
|
|||
}
|
||||
opt = opt || {};
|
||||
|
||||
var config = makeConfig(hash, opt.password);
|
||||
var config = makeConfig(hash, opt);
|
||||
var Session = { cb: cb, hasNetwork: Boolean(opt.network) };
|
||||
|
||||
config.onReady = function (info) {
|
||||
|
@ -82,7 +83,7 @@ define([
|
|||
}
|
||||
opt = opt || {};
|
||||
|
||||
var config = makeConfig(hash, opt.password);
|
||||
var config = makeConfig(hash, opt);
|
||||
var Session = { cb: cb, };
|
||||
|
||||
config.onReady = function (info) {
|
||||
|
|
|
@ -512,6 +512,10 @@ define([
|
|||
|
||||
optsPut = optsPut || {};
|
||||
var optsGet = {};
|
||||
|
||||
if (parsed.type === 'poll') { optsGet.initialState = '{}'; }
|
||||
if (parsed2.type === 'poll') { optsPut.initialState = '{}'; }
|
||||
|
||||
Nthen(function (waitFor) {
|
||||
if (parsed.hashData && parsed.hashData.password) {
|
||||
common.getPadAttribute('password', waitFor(function (err, password) {
|
||||
|
|
|
@ -479,10 +479,11 @@ define([
|
|||
|
||||
Store.addPad = function (clientId, data, cb) {
|
||||
if (!data.href && !data.roHref) { return void cb({error:'NO_HREF'}); }
|
||||
var secret;
|
||||
if (!data.roHref) {
|
||||
var parsed = Hash.parsePadUrl(data.href);
|
||||
if (parsed.hashData.type === "pad") {
|
||||
var secret = Hash.getSecrets(parsed.type, parsed.hash, data.password);
|
||||
secret = Hash.getSecrets(parsed.type, parsed.hash, data.password);
|
||||
data.roHref = '/' + parsed.type + '/#' + Hash.getViewHashFromKeys(secret);
|
||||
}
|
||||
}
|
||||
|
@ -490,7 +491,7 @@ define([
|
|||
if (data.owners) { pad.owners = data.owners; }
|
||||
if (data.expire) { pad.expire = data.expire; }
|
||||
if (data.password) { pad.password = data.password; }
|
||||
if (data.channel) { pad.channel = data.channel; }
|
||||
if (data.channel || secret) { pad.channel = data.channel || secret.channel; }
|
||||
store.manager.addPad(data.path, pad, function (e) {
|
||||
if (e) { return void cb({error: e}); }
|
||||
sendDriveEvent('DRIVE_CHANGE', {
|
||||
|
|
Loading…
Reference in New Issue