mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-04-13 09:42:01 +00:00
Banning users.
This commit is contained in:
parent
ad145d2b21
commit
811520ef0c
1 changed files with 13 additions and 0 deletions
|
@ -254,6 +254,10 @@ BANNED_USER_AGENTS = (
|
||||||
'missing',
|
'missing',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
BANNED_USERNAMES = (
|
||||||
|
'ark4diusz',
|
||||||
|
)
|
||||||
|
|
||||||
class UserAgentBanMiddleware:
|
class UserAgentBanMiddleware:
|
||||||
def process_request(self, request):
|
def process_request(self, request):
|
||||||
user_agent = request.environ.get('HTTP_USER_AGENT', 'missing').lower()
|
user_agent = request.environ.get('HTTP_USER_AGENT', 'missing').lower()
|
||||||
|
@ -274,3 +278,12 @@ class UserAgentBanMiddleware:
|
||||||
|
|
||||||
return HttpResponse(json.encode(data), status=403, mimetype='text/json')
|
return HttpResponse(json.encode(data), status=403, mimetype='text/json')
|
||||||
|
|
||||||
|
if request.user.is_authenticated() and any(username == request.user.username for username in BANNED_USERNAMES):
|
||||||
|
data = {
|
||||||
|
'error': 'User banned: %s' % request.user.username,
|
||||||
|
'code': -1
|
||||||
|
}
|
||||||
|
logging.user(request, "~FB~SN~BBBanned Username: ~SB%s / %s (%s)" % (request.user, request.path, request.META))
|
||||||
|
|
||||||
|
return HttpResponse(json.encode(data), status=403, mimetype='text/json')
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue