Only generate lowercase prepaid codes

Will be easier to make them case-insensitive later if needed.
This commit is contained in:
Matt Lott 2015-10-07 14:06:09 -07:00
parent 5ff3b1606c
commit 32441f1c8d
2 changed files with 2 additions and 2 deletions

View file

@ -51,7 +51,7 @@ function generateNewCode(done)
function createCode(length)
{
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
var possible = "abcdefghijklmnopqrstuvwxyz0123456789";
for( var i=0; i < length; i++ )
text += possible.charAt(Math.floor(Math.random() * possible.length));

View file

@ -6,7 +6,7 @@ PrepaidSchema.index({code: 1}, { unique: true })
PrepaidSchema.statics.generateNewCode = (done) ->
tryCode = ->
code = _.sample("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 8).join('')
code = _.sample("abcdefghijklmnopqrstuvwxyz0123456789", 8).join('')
Prepaid.findOne code: code, (err, prepaid) ->
return done() if err
return done(code) unless prepaid