1
0
Fork 0
mirror of https://gitlab.com/SIGBUS/nyaa.git synced 2024-12-22 15:10:01 +00:00

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.
This commit is contained in:
Nicolas F 2017-10-08 04:16:24 +02:00 committed by Arylide
parent 9e87e810af
commit 37546354a7

View file

@ -37,9 +37,17 @@ def login():
'<strong>Login failed!</strong> Incorrect username or password.'), 'danger') '<strong>Login failed!</strong> Incorrect username or password.'), 'danger')
return flask.redirect(flask.url_for('account.login')) return flask.redirect(flask.url_for('account.login'))
if user.is_banned:
ban_reason = models.Ban.banned(user.id, None).first().reason
ban_str = ('<strong>Login failed!</strong> 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: if user.status != models.UserStatusType.ACTIVE:
flask.flash(flask.Markup( flask.flash(flask.Markup(
'<strong>Login failed!</strong> Account is not activated or banned.'), 'danger') '<strong>Login failed!</strong> Account is not activated.'), 'danger')
return flask.redirect(flask.url_for('account.login')) return flask.redirect(flask.url_for('account.login'))
user.last_login_date = datetime.utcnow() user.last_login_date = datetime.utcnow()