add a unique id to user objects, define a getter

This commit is contained in:
ansuz
2017-03-24 12:17:49 +01:00
parent d1c32ea1f8
commit 40f5e1706f
2 changed files with 16 additions and 0 deletions

View File

@@ -145,6 +145,12 @@ define([
proxy.allowUserFeedback = true;
}
if (typeof(proxy.uid) !== 'string' || proxy.uid.length !== 32) {
// even anonymous users should have a persistent, unique-ish id
console.log('generating a persistent identifier');
proxy.uid = Cryptpad.createChannelId();
}
proxy.on('change', [Cryptpad.displayNameKey], function (o, n, p) {
if (typeof(n) !== "string") { return; }
Cryptpad.changeDisplayName(n);
@@ -156,6 +162,7 @@ define([
var init = function (f, Cryptpad) {
if (!Cryptpad || initialized) { return; }
initialized = true;
var hash = Cryptpad.getUserHash() || localStorage.FS_hash || Cryptpad.createRandomHash();
if (!hash) {
throw new Error('[Store.init] Unable to find or create a drive hash. Aborting...');