feat(front): use uuid for random ids

This commit is contained in:
Florent Chehab 2020-05-12 20:01:57 +02:00
parent 0be0baf655
commit 25bcdee083
No known key found for this signature in database
GPG Key ID: 9A0CE018889EA246
3 changed files with 27 additions and 8 deletions

25
package-lock.json generated
View File

@ -7683,6 +7683,12 @@
"psl": "^1.1.28",
"punycode": "^2.1.1"
}
},
"uuid": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
"dev": true
}
}
},
@ -11249,6 +11255,11 @@
"psl": "^1.1.24",
"punycode": "^1.4.1"
}
},
"uuid": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A=="
}
}
},
@ -12794,9 +12805,9 @@
"integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM="
},
"uuid": {
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz",
"integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA=="
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.1.0.tgz",
"integrity": "sha512-CI18flHDznR0lq54xBycOVmphdCYnQLKn8abKn7PXUiKUGdEd+/l9LWNJmugXel4hXq7S+RMNl34ecyC9TntWg=="
},
"uws": {
"version": "0.14.5",
@ -13604,6 +13615,14 @@
"requires": {
"ansi-colors": "^3.0.0",
"uuid": "^3.3.2"
},
"dependencies": {
"uuid": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
"dev": true
}
}
},
"webpack-merge": {

View File

@ -33,12 +33,13 @@
"express": "4.*",
"formidable": "1.*",
"fs-extra": "7.*",
"jquery-ui-rotatable": "^1.1.0",
"html2canvas": "^1.0.0-rc.5",
"jquery-ui-rotatable": "^1.1.0",
"js-yaml": "3.13.1",
"jsdom": "^14.0.0",
"pdfjs-dist": "^2.3.200",
"socket.io": "2.*",
"uuid": "^8.1.0",
"webdav": "^2.8.0"
},
"devDependencies": {

View File

@ -10,16 +10,15 @@ import ReadOnlyService from "./services/ReadOnlyService";
import InfoService from "./services/InfoService";
import { getQueryVariable, getSubDir } from "./utils";
import ConfigService from "./services/ConfigService";
import { v4 as uuidv4 } from "uuid";
let whiteboardId = getQueryVariable("whiteboardid");
const randomid = getQueryVariable("randomid");
if (randomid && !whiteboardId) {
//set random whiteboard on empty whiteboardid
whiteboardId = Array(2)
.fill(null)
.map(() => Math.random().toString(36).substr(2))
.join("");
whiteboardId = uuidv4();
const urlParams = new URLSearchParams(window.location.search);
urlParams.delete("randomid");
urlParams.set("whiteboardid", whiteboardId);
window.location.search = urlParams;
}