diff --git a/nyaa/views/main.py b/nyaa/views/main.py
index e82e7ac..d9f9789 100644
--- a/nyaa/views/main.py
+++ b/nyaa/views/main.py
@@ -7,6 +7,7 @@ import flask
from flask_paginate import Pagination
from nyaa import models
+from nyaa.extensions import db
from nyaa.search import (DEFAULT_MAX_SEARCH_RESULT, DEFAULT_PER_PAGE, SERACH_PAGINATE_DISPLAY_MSG,
_generate_query_string, search_db, search_elastic)
from nyaa.utils import chain_get
@@ -40,6 +41,12 @@ def before_request():
flask.session.permanent = True
flask.session.modified = True
+ ip = ip_address(flask.request.remote_addr)
+ if user.last_login_ip != ip:
+ user.last_login_ip = ip.packed
+ db.session.add(user)
+ db.session.commit()
+
# Check if user is banned on POST
if flask.request.method == 'POST':
ip = ip_address(flask.request.remote_addr).packed
diff --git a/nyaa/views/torrents.py b/nyaa/views/torrents.py
index 2a55ff2..3f1a34b 100644
--- a/nyaa/views/torrents.py
+++ b/nyaa/views/torrents.py
@@ -99,7 +99,8 @@ def edit_torrent(torrent_id):
flask.abort(403)
torrent_user_level = torrent.user and torrent.user.level
- if editor and editor.is_moderator and (torrent_user_level is None or editor.level > torrent_user_level):
+ if editor and editor.is_moderator and \
+ (torrent_user_level is None or editor.level > torrent_user_level):
ban_form = forms.BanForm()
if flask.request.method == 'POST' and form.submit.data and form.validate():