Small fix
[vchess.git] / server / utils / tokenGenerator.js
CommitLineData
0234201f 1function randString() {
dac39588 2 return Math.random().toString(36).substr(2); // remove `0.`
badeb466 3}
0bd5933d 4
0234201f 5module.exports = function(tokenLength) {
dac39588 6 let res = "";
866842c3 7 // 10 = min length of a rand() string
0234201f
BA
8 const nbRands = Math.ceil(tokenLength/10);
9 for (let i = 0; i < nbRands; i++) res += randString();
866842c3 10 return res.substr(0, tokenLength);
0bd5933d 11}