mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-13 13:35:30 -04:00
Smarter fix for #810, since not all 24-character strings are like MongoDB ids.
This commit is contained in:
parent
137d2b0fd4
commit
fc9d30ccae
2 changed files with 3 additions and 5 deletions
|
@ -194,7 +194,7 @@ class CocoModel extends Backbone.Model
|
|||
return model
|
||||
|
||||
@isObjectID: (s) ->
|
||||
s.length is 24 and s.match(/[a-z0-9]/gi)?.length is 24
|
||||
s.length is 24 and s.match(/[a-f0-9]/gi)?.length is 24
|
||||
|
||||
hasReadAccess: (actor) ->
|
||||
# actor is a User object
|
||||
|
|
|
@ -22,13 +22,11 @@ module.exports.NamedPlugin = (schema) ->
|
|||
schema.methods.checkSlugConflicts = (done) ->
|
||||
slug = @get('slug')
|
||||
|
||||
try
|
||||
id = mongoose.Types.ObjectId.createFromHexString(slug)
|
||||
if slug.length is 24 and slug.match(/[a-f0-9]/gi)?.length is 24
|
||||
err = new Error('Bad name.')
|
||||
err.response = {message:'cannot be like a MondoDB id, Mr Hacker.', property:'name'}
|
||||
err.response = {message: 'cannot be like a MongoDB ID, Mr. Hacker.', property: 'name'}
|
||||
err.code = 422
|
||||
done(err)
|
||||
catch e
|
||||
|
||||
query = { slug:slug }
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue