From 37546354a762418bc360462c585016973aea22b4 Mon Sep 17 00:00:00 2001 From: Nicolas F Date: Sun, 8 Oct 2017 04:16:24 +0200 Subject: [PATCH] Explicitly tell users they were banned (#379) This tells users who are banned the reason that they are banned, and doesn't show the same message for inactive users. IP banned users are still just shown the boring 403 page. --- nyaa/views/account.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/nyaa/views/account.py b/nyaa/views/account.py index 4727198..2736147 100644 --- a/nyaa/views/account.py +++ b/nyaa/views/account.py @@ -37,9 +37,17 @@ def login(): 'Login failed! Incorrect username or password.'), 'danger') return flask.redirect(flask.url_for('account.login')) + if user.is_banned: + ban_reason = models.Ban.banned(user.id, None).first().reason + ban_str = ('Login failed! You are banned with the ' + 'reason "{0}" If you believe that this is a mistake, contact ' + 'a moderator on IRC.'.format(ban_reason)) + flask.flash(flask.Markup(ban_str), 'danger') + return flask.redirect(flask.url_for('account.login')) + if user.status != models.UserStatusType.ACTIVE: flask.flash(flask.Markup( - 'Login failed! Account is not activated or banned.'), 'danger') + 'Login failed! Account is not activated.'), 'danger') return flask.redirect(flask.url_for('account.login')) user.last_login_date = datetime.utcnow()