mirror of
https://github.com/timvisee/send.git
synced 2026-04-18 21:54:11 -04:00
added oauth refresh token support
This commit is contained in:
@@ -70,6 +70,10 @@ module.exports = {
|
||||
const token = authHeader.split(' ')[1];
|
||||
req.user = await fxa.verify(token);
|
||||
}
|
||||
return next();
|
||||
if (req.user) {
|
||||
next();
|
||||
} else {
|
||||
res.sendStatus(401);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -13,9 +13,6 @@ function id(user, kid) {
|
||||
|
||||
module.exports = {
|
||||
async get(req, res) {
|
||||
if (!req.user) {
|
||||
return res.sendStatus(401);
|
||||
}
|
||||
const kid = req.params.id;
|
||||
try {
|
||||
const fileId = id(req.user, kid);
|
||||
@@ -32,9 +29,6 @@ module.exports = {
|
||||
},
|
||||
|
||||
async post(req, res) {
|
||||
if (!req.user) {
|
||||
return res.sendStatus(401);
|
||||
}
|
||||
const kid = req.params.id;
|
||||
try {
|
||||
const limiter = new Limiter(1024 * 1024 * 10);
|
||||
|
||||
@@ -41,13 +41,20 @@ module.exports = function(ws, req) {
|
||||
? config.max_downloads
|
||||
: config.anon_max_downloads;
|
||||
|
||||
if (config.fxa_required && !user) {
|
||||
ws.send(
|
||||
JSON.stringify({
|
||||
error: 401
|
||||
})
|
||||
);
|
||||
return ws.close();
|
||||
}
|
||||
if (
|
||||
!metadata ||
|
||||
!auth ||
|
||||
timeLimit <= 0 ||
|
||||
timeLimit > maxExpireSeconds ||
|
||||
dlimit > maxDownloads ||
|
||||
(config.fxa_required && !user)
|
||||
dlimit > maxDownloads
|
||||
) {
|
||||
ws.send(
|
||||
JSON.stringify({
|
||||
|
||||
Reference in New Issue
Block a user