Use the same username for all pads

pull/1/head
yflory 8 years ago
parent 73d5ea967b
commit 79884e2400

@ -186,7 +186,7 @@ define([
name: myUserName name: myUserName
}; };
addToUserList(myData); addToUserList(myData);
Cryptpad.setPadAttribute('username', myUserName, function (err, data) { Cryptpad.setAttribute('username', myUserName, function (err, data) {
if (err) { if (err) {
console.log("Couldn't set username"); console.log("Couldn't set username");
console.error(err); console.error(err);
@ -197,7 +197,7 @@ define([
}; };
var getLastName = function (cb) { var getLastName = function (cb) {
Cryptpad.getPadAttribute('username', function (err, userName) { Cryptpad.getAttribute('username', function (err, userName) {
cb(err, userName || ''); cb(err, userName || '');
}); });
}; };

@ -318,6 +318,12 @@ define([
cb(err, data); cb(err, data);
}); });
}; };
var setAttribute = common.setAttribute = function (attr, value, cb, legacy) {
getStore(legacy).set(["cryptpad", attr].join('.'), value, function (err, data) {
cb(err, data);
});
};
// STORAGE // STORAGE
var getPadAttribute = common.getPadAttribute = function (attr, cb, legacy) { var getPadAttribute = common.getPadAttribute = function (attr, cb, legacy) {
@ -325,6 +331,12 @@ define([
cb(err, data); cb(err, data);
}); });
}; };
var getAttribute = common.getAttribute = function (attr, cb, legacy) {
getStore(legacy).get(["cryptpad", attr].join('.'), function (err, data) {
cb(err, data);
});
};
// STORAGE // STORAGE
/* fetch and migrate your pad history from localStorage */ /* fetch and migrate your pad history from localStorage */

@ -269,7 +269,7 @@ define([
}; };
var getLastName = function (cb) { var getLastName = function (cb) {
Cryptpad.getPadAttribute('username', function (err, userName) { Cryptpad.getAttribute('username', function (err, userName) {
cb(err, userName || ''); cb(err, userName || '');
}); });
}; };
@ -287,7 +287,7 @@ define([
addToUserList(myData); addToUserList(myData);
editor.fire('change'); editor.fire('change');
Cryptpad.setPadAttribute('username', newName, function (err, data) { Cryptpad.setAttribute('username', newName, function (err, data) {
if (err) { if (err) {
console.error("Couldn't set username"); console.error("Couldn't set username");
} }

Loading…
Cancel
Save