diff --git a/files/classes/user.py b/files/classes/user.py index 965aac7fd..07004aa89 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -533,14 +533,6 @@ class User(Base): g.db.add(self) - def unban(self): - - self.is_banned = 0 - self.unban_utc = 0 - - g.db.add(self) - g.db.commit() - @property @lazy diff --git a/files/routes/admin.py b/files/routes/admin.py index d244172d4..84d2f6698 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -39,7 +39,9 @@ def revert_actions(v, username): users = g.db.query(User).options(lazyload('*')).options(lazyload('*')).filter_by(is_banned=user.id).all() for user in users: - user.unban() + user.is_banned = 0 + user.unban_utc = 0 + g.db.add(user) g.db.commit() return {"message": "Admin actions reverted!"} @@ -936,12 +938,16 @@ def unban_user(user_id, v): if not user: abort(400) - user.unban() + user.is_banned = 0 + user.unban_utc = 0 + g.db.add(user) if request.values.get("alts", ""): for x in user.alts: if x.admin_level == 0: - x.unban() + x.is_banned = 0 + x.unban_utc = 0 + g.db.add(x) send_notification(NOTIFICATIONS_ACCOUNT, user, "Your account has been reinstated. Please carefully review and abide by the [rules](/post/2510) to ensure that you don't get suspended again.") diff --git a/files/routes/login.py b/files/routes/login.py index b7e4f7bb8..e3587a36b 100644 --- a/files/routes/login.py +++ b/files/routes/login.py @@ -133,7 +133,9 @@ def login_post(): abort(400) if account.is_banned and account.unban_utc > 0 and time.time() > account.unban_utc: - account.unban() + account.is_banned = 0 + account.unban_utc = 0 + g.db.add(account) # set session and user id session["user_id"] = account.id