Use crypto module for token generation

This commit is contained in:
Shane Kilkelly 2017-10-12 11:36:45 +01:00
parent 22c5f41fb6
commit 6feedf5520

View file

@ -1,12 +1,12 @@
crypto = require 'crypto'
module.exports = ProjectTokenGenerator =
readOnlyToken: () ->
length = 12
tokenAlpha = 'bcdfghjkmnpqrstvwxyz'
result = ''
for _n in [1..length]
i = Math.floor(Math.floor(Math.random() * tokenAlpha.length))
result += tokenAlpha[i]
crypto.randomBytes(length).map( (a) -> result += tokenAlpha[a % tokenAlpha.length] )
return result
readAndWriteToken: () ->