mirror of
https://github.com/simon987/nyaa.git
synced 2025-12-14 07:39:03 +00:00
config: add anonymous upload/registration limiting (#537)
This commit is contained in:
committed by
Arylide
parent
e4780aa47d
commit
8365894268
@@ -172,7 +172,11 @@ def handle_torrent_upload(upload_form, uploading_user=None, fromAPI=False):
|
||||
raise TorrentExtraValidationException()
|
||||
|
||||
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 "
|
||||
"uploading anonymously."]
|
||||
raise TorrentExtraValidationException()
|
||||
|
||||
@@ -90,7 +90,17 @@ def register():
|
||||
user.last_login_ip = user.registration_ip
|
||||
db.session.add(user)
|
||||
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. '
|
||||
'Please <a href="{}">ask a moderator</a> to manually '
|
||||
'activate your account <a href="{}">\'{}\'</a>.'
|
||||
|
||||
Reference in New Issue
Block a user