diff --git a/src/routes/simpleauth.js b/src/routes/simpleauth.js index be4ea4239..8f2b67974 100644 --- a/src/routes/simpleauth.js +++ b/src/routes/simpleauth.js @@ -10,7 +10,7 @@ exports = module.exports = { var assert = require('assert'), HttpError = require('connect-lastmile').HttpError, HttpSuccess = require('connect-lastmile').HttpSuccess, - ClientsError = require('../clients.js').ClientsError, + DatabaseError = require('../databaseerror.js'), UserError = require('../user.js').UserError, simpleauth = require('../simpleauth.js'); @@ -22,7 +22,7 @@ function login(req, res, next) { if (typeof req.body.password !== 'string') return next(new HttpError(400, 'password is required')); simpleauth.login(req.body.clientId, req.body.username, req.body.password, function (error, result) { - if (error && error.reason === ClientsError.NOT_FOUND) return next(new HttpError(401, 'Unknown client')); + if (error && error.reason === DatabaseError.NOT_FOUND) return next(new HttpError(401, 'Unknown client')); if (error && error.reason === UserError.NOT_FOUND) return next(new HttpError(401, 'Forbidden')); if (error && error.reason === UserError.WRONG_PASSWORD) return next(new HttpError(401, 'Forbidden')); if (error) return next(new HttpError(500, error)); @@ -33,7 +33,7 @@ function login(req, res, next) { id: result.user.id, username: result.user.username, email: result.user.email, - admin: result.user.admin + admin: !!result.user.admin } }; diff --git a/src/simpleauth.js b/src/simpleauth.js index 5b879ef86..5910f9e74 100644 --- a/src/simpleauth.js +++ b/src/simpleauth.js @@ -9,7 +9,7 @@ var assert = require('assert'), debug = require('debug')('box:simpleauth'), user = require('./user.js'), tokendb = require('./tokendb.js'), - clientdb = require('./clientdb.js'); + clients = require('./clients.js'); function login(clientId, username, password, callback) { assert.strictEqual(typeof clientId, 'string'); @@ -19,7 +19,7 @@ function login(clientId, username, password, callback) { debug('login: client %s and user %s', clientId, username); - clientdb.get(clientId, function (error, clientObject) { + clients.get(clientId, function (error, clientObject) { if (error) return callback(error); user.verify(username, password, function (error, userObject) {