Use standard method for getting an objectId
This commit is contained in:
parent
dbac3d7fe5
commit
c6f0b16e5c
1 changed files with 1 additions and 3 deletions
|
@ -1,7 +1,5 @@
|
||||||
import passwords from 'passwords';
|
import passwords from 'passwords';
|
||||||
import auth from 'basic-auth';
|
import auth from 'basic-auth';
|
||||||
import mongoSetup from 'mongodb-promisified';
|
|
||||||
const objectID = mongoSetup().objectID;
|
|
||||||
import debugname from 'debug';
|
import debugname from 'debug';
|
||||||
const debug = debugname('hostr-api:auth');
|
const debug = debugname('hostr-api:auth');
|
||||||
|
|
||||||
|
@ -18,7 +16,7 @@ export default function* (next) {
|
||||||
const userToken = yield this.redis.get(this.req.headers.authorization.substr(1));
|
const userToken = yield this.redis.get(this.req.headers.authorization.substr(1));
|
||||||
this.assert(userToken, 401, '{"error": {"message": "Invalid token.", "code": 606}}');
|
this.assert(userToken, 401, '{"error": {"message": "Invalid token.", "code": 606}}');
|
||||||
debug('Token found');
|
debug('Token found');
|
||||||
user = yield Users.findOne({'_id': objectID(userToken)});
|
user = yield Users.findOne({'_id': this.db.objectID(userToken)});
|
||||||
} else {
|
} else {
|
||||||
const authUser = auth(this);
|
const authUser = auth(this);
|
||||||
this.assert(authUser, 401, badLoginMsg);
|
this.assert(authUser, 401, badLoginMsg);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue