mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-18 17:21:33 +00:00
feat: limit upload to specific usergroups
This commit is contained in:
parent
38388e90c7
commit
48488667c8
@ -7,6 +7,14 @@ module.exports = {
|
||||
*/
|
||||
private: true,
|
||||
|
||||
/*
|
||||
If set, only the specified group AND any groups higher than it
|
||||
will be allowed to upload new files.
|
||||
Any other groups, assuming registered, will still be able to manage their previously uploaded files.
|
||||
*/
|
||||
privateUploadGroup: null, // Other group names in controllers/permissionController.js
|
||||
privateUploadCustomRespond: null,
|
||||
|
||||
/*
|
||||
If true, users will be able to create accounts and access their uploaded files.
|
||||
*/
|
||||
|
@ -264,6 +264,12 @@ self.upload = async (req, res, next) => {
|
||||
user = await utils.assertUser(req.headers.token)
|
||||
}
|
||||
|
||||
if (config.privateUploadGroup) {
|
||||
if (!user || !perms.is(user, config.privateUploadGroup)) {
|
||||
throw new ClientError(config.privateUploadCustomRespond || 'Your usergroup is not permitted to upload new files.', { statusCode: 403 })
|
||||
}
|
||||
}
|
||||
|
||||
let albumid = parseInt(req.headers.albumid || req.params.albumid)
|
||||
if (isNaN(albumid)) albumid = null
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user