cmd/syncthing: Use API to generate API Key and folder ID (fixes #3179)
Expose a random string generator in the API and use it when the GUI needs random strings for API key and folder ID. GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3192
This commit is contained in:
committed by
Audrius Butkevicius
parent
e6b78e5d56
commit
da5010d37a
@@ -89,19 +89,6 @@ function decimals(val, num) {
|
||||
return decs;
|
||||
}
|
||||
|
||||
function randomString(len) {
|
||||
var chars = '01234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-';
|
||||
return randomStringFromCharset(len, chars);
|
||||
}
|
||||
|
||||
function randomStringFromCharset(len, charset) {
|
||||
var result = '';
|
||||
for (var i = 0; i < len; i++) {
|
||||
result += charset[Math.round(Math.random() * (charset.length - 1))];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function isEmptyObject(obj) {
|
||||
var name;
|
||||
for (name in obj) {
|
||||
|
||||
Reference in New Issue
Block a user