mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Use crypto module for token generation
This commit is contained in:
parent
22c5f41fb6
commit
6feedf5520
1 changed files with 3 additions and 3 deletions
|
@ -1,12 +1,12 @@
|
||||||
|
crypto = require 'crypto'
|
||||||
|
|
||||||
module.exports = ProjectTokenGenerator =
|
module.exports = ProjectTokenGenerator =
|
||||||
|
|
||||||
readOnlyToken: () ->
|
readOnlyToken: () ->
|
||||||
length = 12
|
length = 12
|
||||||
tokenAlpha = 'bcdfghjkmnpqrstvwxyz'
|
tokenAlpha = 'bcdfghjkmnpqrstvwxyz'
|
||||||
result = ''
|
result = ''
|
||||||
for _n in [1..length]
|
crypto.randomBytes(length).map( (a) -> result += tokenAlpha[a % tokenAlpha.length] )
|
||||||
i = Math.floor(Math.floor(Math.random() * tokenAlpha.length))
|
|
||||||
result += tokenAlpha[i]
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
readAndWriteToken: () ->
|
readAndWriteToken: () ->
|
||||||
|
|
Loading…
Reference in a new issue