Move API endpoints to /api
This commit is contained in:
@ -27,7 +27,7 @@ function indexRedirect(req, res, entry) {
|
||||
}
|
||||
|
||||
function stripLeadingSegment(name) {
|
||||
return name.replace(/^[^\/]+\/?/, "");
|
||||
return name.replace(/^[^/]+\/?/, "");
|
||||
}
|
||||
|
||||
function searchEntries(tarballStream, entryName, wantsHTML) {
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
const basicAuth = require("basic-auth");
|
||||
|
||||
const AuthAPI = require("../AuthAPI");
|
||||
|
||||
const ReadMethods = { GET: true, HEAD: true };
|
||||
@ -10,7 +12,10 @@ function userToken(req, res, next) {
|
||||
return next();
|
||||
}
|
||||
|
||||
const token = (ReadMethods[req.method] ? req.query : req.body).token;
|
||||
const credentials = basicAuth(req);
|
||||
const token = credentials
|
||||
? credentials.pass
|
||||
: (ReadMethods[req.method] ? req.query : req.body).token;
|
||||
|
||||
if (!token) {
|
||||
req.user = null;
|
||||
|
||||
Reference in New Issue
Block a user