Skip to content

Instantly share code, notes, and snippets.

@gcarothers
Created June 4, 2015 17:38
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save gcarothers/e2bfb2ec36023add0365 to your computer and use it in GitHub Desktop.
def forbid_user_messages(request, user):
"""Provide messaging to users who have an active session and become
disabled for some reason."""
if user.inactive and not request.is_xhr:
# Log out inactive users.
headers = forget(request)
if user.trial_expiration:
error_msg = """Your Lex Machina trial has expired.
Please <a href="mailto:sales@lexmachina.com">contact sales</a>
to subscribe."""
else:
error_msg = """Your Lex Machina account has been disabled.
If you have any questions, please
<a href="mailto:support@lexmachina.com">contact our customer
support</a>."""
request.session.flash(error_msg, 'error', allow_duplicate=False)
raise HTTPForbidden(headers=headers)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment