mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Generate tokens by default
This commit is contained in:
parent
562b2db600
commit
441c207953
1 changed files with 15 additions and 2 deletions
|
@ -7,6 +7,13 @@ sanitize = require('sanitizer')
|
|||
concreteObjectId = require('mongoose').Types.ObjectId
|
||||
Errors = require "../Features/Errors/Errors"
|
||||
|
||||
generateToken = (length) ->
|
||||
tokenAlpha = 'bcdfghjkmnpqrstvwxyz'
|
||||
result = ''
|
||||
for _n in [1..length]
|
||||
i = Math.floor(Math.floor(Math.random() * tokenAlpha.length))
|
||||
result += tokenAlpha[i]
|
||||
return result
|
||||
|
||||
Schema = mongoose.Schema
|
||||
ObjectId = Schema.ObjectId
|
||||
|
@ -34,8 +41,14 @@ ProjectSchema = new Schema
|
|||
imageName : { type: String }
|
||||
track_changes : { type: Object }
|
||||
tokens :
|
||||
readOnly : { type: String }
|
||||
readAndWrite : { type: String }
|
||||
readOnly : {
|
||||
type: String,
|
||||
default: generateToken(14)
|
||||
}
|
||||
readAndWrite : {
|
||||
type: String,
|
||||
default: Math.random().toString().slice(2, 10) + generateToken(12)
|
||||
}
|
||||
tokenAccessReadOnly_refs : [ type:ObjectId, ref:'User' ]
|
||||
tokenAccessReadAndWrite_refs : [ type:ObjectId, ref:'User' ]
|
||||
overleaf :
|
||||
|
|
Loading…
Reference in a new issue