mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-17 22:14:25 +01:00
Add a wrapper for get_user_ips
This commit is contained in:
@@ -43,7 +43,7 @@ from CTFd.utils.user import (
|
||||
get_current_team,
|
||||
get_current_user,
|
||||
get_ip,
|
||||
get_user_ips,
|
||||
get_current_user_ips,
|
||||
is_admin,
|
||||
)
|
||||
|
||||
@@ -177,7 +177,7 @@ def init_request_processors(app):
|
||||
return
|
||||
|
||||
if authed():
|
||||
user_ips = get_user_ips(user_id=session["id"])
|
||||
user_ips = get_current_user_ips()
|
||||
ip = get_ip()
|
||||
if ip not in user_ips:
|
||||
visit = Tracking(ip=get_ip(), user_id=session["id"])
|
||||
|
||||
@@ -81,6 +81,14 @@ def get_ip(req=None):
|
||||
return remote_addr
|
||||
|
||||
|
||||
def get_current_user_ips():
|
||||
if authed():
|
||||
return get_user_ips(user_id=session["id"])
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
@cache.memoize
|
||||
def get_user_ips(user_id):
|
||||
addrs = (
|
||||
Tracking.query.with_entities(Tracking.ip.distinct())
|
||||
|
||||
Reference in New Issue
Block a user