simplified unpairing
This commit is contained in:
parent
e50567ff81
commit
6ed979b1af
3 changed files with 14 additions and 44 deletions
15
lib/app.js
15
lib/app.js
|
|
@ -89,13 +89,18 @@ module.exports = function (options) {
|
|||
if (options.https) {
|
||||
authMiddleware = function(req, res, next) {
|
||||
var fingerprint = req.connection.getPeerCertificate().fingerprint;
|
||||
var e = new Error('Unauthorized');
|
||||
e.status = 401;
|
||||
|
||||
config.isAuthorized(fingerprint, function (err, device) {
|
||||
if (err) { return next(e); }
|
||||
if (!device) { return next(e); }
|
||||
req.device = device;
|
||||
if (err) {
|
||||
var serverError = new Error('Internal Server Error');
|
||||
serverError.status = 500;
|
||||
return next(serverError);
|
||||
}
|
||||
if (!device) {
|
||||
var pairError = new Error('Not Found');
|
||||
pairError.status = 404;
|
||||
return next(pairError);
|
||||
}
|
||||
next();
|
||||
});
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue