Skip to content

Commit 90893a1

Browse files
author
Miel Vander Sande
committed
Call Forbidden html template
1 parent efaf783 commit 90893a1

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

lib/controllers/WebIDControllerExtension.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,21 @@ var http = require('http'),
77
N3 = require('n3'),
88
n3parser = N3.Parser,
99
N3Util = N3.Util,
10-
Util = require('../Util');
10+
Util = require('../Util'),
11+
Controller = require('./Controller');
1112

1213
var CERT_NS = 'http://www.w3.org/ns/auth/cert#';
1314

1415
// Creates a new WebIDControllerExtension
1516
function WebIDControllerExtension(settings) {
1617
if (!(this instanceof WebIDControllerExtension))
1718
return new WebIDControllerExtension(settings);
19+
Controller.call(this, settings);
1820

1921
this._cache = lru(50);
2022
this._protocol = settings.protocol;
2123
}
24+
Controller.extend(WebIDControllerExtension);
2225

2326
// Add WebID Link headers
2427
WebIDControllerExtension.prototype._handleRequest = function (request, response, next, settings) {
@@ -94,14 +97,22 @@ WebIDControllerExtension.prototype._verifyWebID = function (webID, modulus, expo
9497
});
9598

9699
req.on('error', function (e) {
97-
callback(null, false, 'Unabled to download' + webID + '. Details: ' + e.message);
100+
callback(null, false, 'Unabled to download ' + webID + ' (' + e.message + ').');
98101
});
99102

100103
req.end();
101104
}
102105
};
103106

104107
WebIDControllerExtension.prototype._handleForbidden = function (request, response, options) {
108+
// Render the 404 message using the appropriate view
109+
var view = this._negotiateView('Forbidden', request, response),
110+
metadata = { url: request.url, prefixes: this._prefixes, datasources: this._datasources, reason: options.reason };
111+
response.writeHead(401);
112+
view.render(metadata, request, response);
113+
};
114+
115+
WebIDControllerExtension.prototype._handleNotAcceptable = function (request, response, options) {
105116
response.writeHead(401, { 'Content-Type': Util.MIME_PLAINTEXT });
106117
response.end('Access to ' + request.url + ' is not allowed, verification for WebID ' + (options.webID || '') + ' failed. Reason: ' + (options.reason || ''));
107118
};

0 commit comments

Comments
 (0)