mirror of https://github.com/JohnHammond/CTFd.git
Add a wrapper for get_user_ips
parent
817b67d1b0
commit
541d7e9cfa
|
@ -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())
|
||||
|
|
Loading…
Reference in New Issue