Remove obsolete anonymous limits
Related to https://gitlab.com/timvisee/send/-/issues/3
This commit is contained in:
parent
9e4c063749
commit
15d37da667
12
app/user.js
12
app/user.js
|
@ -81,21 +81,15 @@ export default class User {
|
||||||
}
|
}
|
||||||
|
|
||||||
get maxSize() {
|
get maxSize() {
|
||||||
return this.loggedIn
|
return this.limits.MAX_FILE_SIZE;
|
||||||
? this.limits.MAX_FILE_SIZE
|
|
||||||
: this.limits.ANON.MAX_FILE_SIZE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get maxExpireSeconds() {
|
get maxExpireSeconds() {
|
||||||
return this.loggedIn
|
return this.limits.MAX_EXPIRE_SECONDS;
|
||||||
? this.limits.MAX_EXPIRE_SECONDS
|
|
||||||
: this.limits.ANON.MAX_EXPIRE_SECONDS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get maxDownloads() {
|
get maxDownloads() {
|
||||||
return this.loggedIn
|
return this.limits.MAX_DOWNLOADS;
|
||||||
? this.limits.MAX_DOWNLOADS
|
|
||||||
: this.limits.ANON.MAX_DOWNLOADS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async metricId() {
|
async metricId() {
|
||||||
|
|
|
@ -2,11 +2,6 @@ const config = require('./config');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
LIMITS: {
|
LIMITS: {
|
||||||
ANON: {
|
|
||||||
MAX_FILE_SIZE: config.anon_max_file_size,
|
|
||||||
MAX_DOWNLOADS: config.anon_max_downloads,
|
|
||||||
MAX_EXPIRE_SECONDS: config.anon_max_expire_seconds
|
|
||||||
},
|
|
||||||
MAX_FILE_SIZE: config.max_file_size,
|
MAX_FILE_SIZE: config.max_file_size,
|
||||||
MAX_DOWNLOADS: config.max_downloads,
|
MAX_DOWNLOADS: config.max_downloads,
|
||||||
MAX_EXPIRE_SECONDS: config.max_expire_seconds,
|
MAX_EXPIRE_SECONDS: config.max_expire_seconds,
|
||||||
|
|
|
@ -39,11 +39,6 @@ const conf = convict({
|
||||||
default: 86400 * 7,
|
default: 86400 * 7,
|
||||||
env: 'MAX_EXPIRE_SECONDS'
|
env: 'MAX_EXPIRE_SECONDS'
|
||||||
},
|
},
|
||||||
anon_max_expire_seconds: {
|
|
||||||
format: Number,
|
|
||||||
default: 86400,
|
|
||||||
env: 'ANON_MAX_EXPIRE_SECONDS'
|
|
||||||
},
|
|
||||||
download_counts: {
|
download_counts: {
|
||||||
format: Array,
|
format: Array,
|
||||||
default: [1, 2, 3, 4, 5, 20, 50, 100],
|
default: [1, 2, 3, 4, 5, 20, 50, 100],
|
||||||
|
@ -54,11 +49,6 @@ const conf = convict({
|
||||||
default: 100,
|
default: 100,
|
||||||
env: 'MAX_DOWNLOADS'
|
env: 'MAX_DOWNLOADS'
|
||||||
},
|
},
|
||||||
anon_max_downloads: {
|
|
||||||
format: Number,
|
|
||||||
default: 5,
|
|
||||||
env: 'ANON_MAX_DOWNLOADS'
|
|
||||||
},
|
|
||||||
max_files_per_archive: {
|
max_files_per_archive: {
|
||||||
format: Number,
|
format: Number,
|
||||||
default: 64,
|
default: 64,
|
||||||
|
@ -120,11 +110,6 @@ const conf = convict({
|
||||||
default: 1024 * 1024 * 1024 * 2.5,
|
default: 1024 * 1024 * 1024 * 2.5,
|
||||||
env: 'MAX_FILE_SIZE'
|
env: 'MAX_FILE_SIZE'
|
||||||
},
|
},
|
||||||
anon_max_file_size: {
|
|
||||||
format: Number,
|
|
||||||
default: 1024 * 1024 * 1024,
|
|
||||||
env: 'ANON_MAX_FILE_SIZE'
|
|
||||||
},
|
|
||||||
l10n_dev: {
|
l10n_dev: {
|
||||||
format: Boolean,
|
format: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
|
|
|
@ -2,7 +2,7 @@ const config = require('../config');
|
||||||
const storage = require('../storage');
|
const storage = require('../storage');
|
||||||
|
|
||||||
module.exports = function(req, res) {
|
module.exports = function(req, res) {
|
||||||
const max = req.user ? config.max_downloads : config.anon_max_downloads;
|
const max = config.max_downloads;
|
||||||
const dlimit = req.body.dlimit;
|
const dlimit = req.body.dlimit;
|
||||||
if (!dlimit || dlimit > max) {
|
if (!dlimit || dlimit > max) {
|
||||||
return res.sendStatus(400);
|
return res.sendStatus(400);
|
||||||
|
|
|
@ -30,15 +30,9 @@ module.exports = function(ws, req) {
|
||||||
const metadata = fileInfo.fileMetadata;
|
const metadata = fileInfo.fileMetadata;
|
||||||
const auth = fileInfo.authorization;
|
const auth = fileInfo.authorization;
|
||||||
const user = await fxa.verify(fileInfo.bearer);
|
const user = await fxa.verify(fileInfo.bearer);
|
||||||
const maxFileSize = user
|
const maxFileSize = config.max_file_size;
|
||||||
? config.max_file_size
|
const maxExpireSeconds = config.max_expire_seconds;
|
||||||
: config.anon_max_file_size;
|
const maxDownloads = config.max_downloads;
|
||||||
const maxExpireSeconds = user
|
|
||||||
? config.max_expire_seconds
|
|
||||||
: config.anon_max_expire_seconds;
|
|
||||||
const maxDownloads = user
|
|
||||||
? config.max_downloads
|
|
||||||
: config.anon_max_downloads;
|
|
||||||
|
|
||||||
if (config.fxa_required && !user) {
|
if (config.fxa_required && !user) {
|
||||||
ws.send(
|
ws.send(
|
||||||
|
|
Loading…
Reference in New Issue