mirror of
https://gitlab.com/SIGBUS/nyaa.git
synced 2024-12-22 13:09:59 +00:00
config: add anonymous upload/registration limiting
This commit is contained in:
parent
e4780aa47d
commit
0ac2ae4207
|
@ -14,6 +14,16 @@ MAINTENANCE_MODE_MESSAGE = 'Site is currently in read-only maintenance mode.'
|
||||||
# Allow logging in during maintenance (without updating last login date)
|
# Allow logging in during maintenance (without updating last login date)
|
||||||
MAINTENANCE_MODE_LOGINS = True
|
MAINTENANCE_MODE_LOGINS = True
|
||||||
|
|
||||||
|
# Block *anonymous* uploads completely
|
||||||
|
RAID_MODE_LIMIT_UPLOADS = False
|
||||||
|
# Message prepended to the full error message (account.py)
|
||||||
|
RAID_MODE_UPLOADS_MESSAGE = 'Anonymous uploads are currently disabled.'
|
||||||
|
|
||||||
|
# Require manual activation for newly registered accounts
|
||||||
|
RAID_MODE_LIMIT_REGISTER = False
|
||||||
|
# Message prepended to the full error message (account.py)
|
||||||
|
RAID_MODE_REGISTER_MESSAGE = 'Registration is currently being limited.'
|
||||||
|
|
||||||
#############
|
#############
|
||||||
## General ##
|
## General ##
|
||||||
#############
|
#############
|
||||||
|
|
|
@ -172,7 +172,11 @@ def handle_torrent_upload(upload_form, uploading_user=None, fromAPI=False):
|
||||||
raise TorrentExtraValidationException()
|
raise TorrentExtraValidationException()
|
||||||
|
|
||||||
if not uploading_user:
|
if not uploading_user:
|
||||||
if models.RangeBan.is_rangebanned(ip_address(flask.request.remote_addr).packed):
|
if app.config['RAID_MODE_LIMIT_UPLOADS']:
|
||||||
|
# XXX TODO: rename rangebanned to something more generic
|
||||||
|
upload_form.rangebanned.errors = [app.config['RAID_MODE_UPLOADS_MESSAGE']]
|
||||||
|
raise TorrentExtraValidationException()
|
||||||
|
elif models.RangeBan.is_rangebanned(ip_address(flask.request.remote_addr).packed):
|
||||||
upload_form.rangebanned.errors = ["Your IP is banned from "
|
upload_form.rangebanned.errors = ["Your IP is banned from "
|
||||||
"uploading anonymously."]
|
"uploading anonymously."]
|
||||||
raise TorrentExtraValidationException()
|
raise TorrentExtraValidationException()
|
||||||
|
|
|
@ -90,7 +90,17 @@ def register():
|
||||||
user.last_login_ip = user.registration_ip
|
user.last_login_ip = user.registration_ip
|
||||||
db.session.add(user)
|
db.session.add(user)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
if models.RangeBan.is_rangebanned(user.registration_ip):
|
|
||||||
|
if app.config['RAID_MODE_LIMIT_REGISTER']:
|
||||||
|
flask.flash(flask.Markup(app.config['RAID_MODE_REGISTER_MESSAGE'] + ' '
|
||||||
|
'Please <a href="{}">ask a moderator</a> to manually '
|
||||||
|
'activate your account <a href="{}">\'{}\'</a>.'
|
||||||
|
.format(flask.url_for('site.help') + '#irchelp',
|
||||||
|
flask.url_for('users.view_user',
|
||||||
|
user_name=user.username),
|
||||||
|
user.username)), 'warning')
|
||||||
|
|
||||||
|
elif models.RangeBan.is_rangebanned(user.registration_ip):
|
||||||
flask.flash(flask.Markup('Your IP is blocked from creating new accounts. '
|
flask.flash(flask.Markup('Your IP is blocked from creating new accounts. '
|
||||||
'Please <a href="{}">ask a moderator</a> to manually '
|
'Please <a href="{}">ask a moderator</a> to manually '
|
||||||
'activate your account <a href="{}">\'{}\'</a>.'
|
'activate your account <a href="{}">\'{}\'</a>.'
|
||||||
|
|
Loading…
Reference in a new issue