Skip to content

Commit cc7183a

Browse files
authored
Add optional parameter for generateSessionID
1 parent fbdc81a commit cc7183a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

backend/SessionIDManager.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,12 @@ exports.getSession = (database, data) => {
119119
/**
120120
* Generates a 16-chars long session ID (using crypto)
121121
*
122-
* @returns {string} The generated session ID
122+
* @param {number} length The length of session id
123+
* @returns {string=} The generated session ID
123124
*/
124-
exports.generateSessionID = () => {
125+
exports.generateSessionID = length => {
125126
let session = "";
126-
for (let i = 0; i < 8; ++i) {
127+
for (let i = 0; i < ((length || 16) / 2); ++i) {
127128
session += (randomBytes(1).readUInt8() & 0xFF).toString(36);
128129
}
129130
return session;

0 commit comments

Comments
 (0)