Implement user-id.verify

This commit is contained in:
Tankred Hase
2016-05-30 16:06:52 +02:00
parent 279992379f
commit f930ee38e9
4 changed files with 31 additions and 7 deletions

View File

@@ -27,10 +27,12 @@ class REST {
/**
* Create an instance of the REST server
* @param {Object} publicKey An instance of the public key controller
* @param {Object} publicKey An instance of the public key service
* @param {Object} userId An instance of the user id service
*/
constructor(publicKey) {
constructor(publicKey, userId) {
this._publicKey = publicKey;
this._userId = userId;
}
/**
@@ -50,9 +52,16 @@ class REST {
ctx.status = 201;
}
/**
* Verify a public key's user id via http GET
* @param {Object} ctx The koa request/response context
*/
*verify(ctx) {
ctx.throw(501, 'Not implemented!');
yield;
let q = { keyid:ctx.query.keyid, nonce:ctx.query.nonce };
if (!util.validateKeyId(q.keyid) && !util.isString(q.nonce)) {
ctx.throw(400, 'Invalid request!');
}
yield this._userId.verify(q);
}
/**