Implement InvalidCredentials error

This commit is contained in:
Juan Cruz Viotti 2014-12-01 10:18:39 -04:00
parent e21c1588c9
commit 551202dd4e
2 changed files with 7 additions and 1 deletions

View File

@ -3,6 +3,7 @@ _ = require('lodash')
token = require('../token/token')
server = require('../server/server')
errors = require('../errors/errors')
config = require('../config')
exports.authenticate = (credentials, callback) ->
@ -32,7 +33,7 @@ exports.parseCredentials = (credentials, callback) ->
result = credentials.split(':')
if result.length isnt 2
error = new Error('Invalid credentials. The expected input is username:password.')
error = new errors.InvalidCredentials()
return callback?(error)
callback? null,

View File

@ -7,6 +7,11 @@ exports.NotFound = class NotFound extends TypedError
@message = "Couldn't find #{name}"
@code = 1
exports.InvalidCredentials = class InvalidCredentials extends TypedError
constructor: ->
@message = 'Invalid credentials'
@code = 1
exports.NotAny = class NotAny extends TypedError
constructor: (name) ->
@message = "You don't have any #{name}"