Add client token authentication

This commit is contained in:
Maxim Rubis
2018-06-06 08:05:34 -04:00
parent d9fca62c17
commit 6a103f3e61
3 changed files with 25 additions and 11 deletions
+14 -6
View File
@@ -104,13 +104,21 @@ export default function(opt) {
return;
}
debug('making new client with id %s', reqId);
const info = await manager.newClient(reqId);
try {
debug('making new client with id %s', reqId);
const info = await manager.newClient(reqId);
const url = schema + '://' + info.id + '.' + ctx.request.host;
info.url = url;
ctx.body = info;
return;
const url = schema + '://' + info.id + '.' + ctx.request.host;
info.url = url;
ctx.body = info;
}
catch(err) {
debug('Error: %s with id %s', err.message, reqId);
ctx.status = 403;
ctx.body = {
message: err.message,
};
}
});
const server = http.createServer();