mirror of
https://github.com/Mistake35/Cedar-Django.git
synced 2026-07-18 00:21:14 +10:00
Finished the merge, Disabling comments, Community bans.
This commit is contained in:
@@ -31,12 +31,17 @@ class ClosedMiddleware(object):
|
||||
return redirect('https://{0}{1}'.format(request.get_host(), request.get_full_path()))
|
||||
"""
|
||||
if request.user.is_authenticated:
|
||||
"""
|
||||
if not request.user.is_active():
|
||||
if request.user.warned_reason:
|
||||
ban_msg = request.user.warned_reason
|
||||
else:
|
||||
ban_msg = 'You are banned.'
|
||||
return HttpResponseForbidden(ban_msg)
|
||||
"""
|
||||
# can just forbid post requests for the time being (but leav our funny logout message :3)
|
||||
if not request.user.is_active() and request.method != 'GET' and request.get_full_path() != '/logout/':
|
||||
return HttpResponseForbidden()
|
||||
# If there isn't a request.session
|
||||
if not request.session.get('passwd'):
|
||||
request.session['passwd'] = request.user.password
|
||||
@@ -44,5 +49,8 @@ class ClosedMiddleware(object):
|
||||
if request.session['passwd'] != request.user.password:
|
||||
logout(request)
|
||||
response = self.get_response(request)
|
||||
if request.user.is_authenticated:
|
||||
# for reverse proxy
|
||||
response['X-Username'] = request.user.username
|
||||
|
||||
return response
|
||||
|
||||
Reference in New Issue
Block a user