fix ratelimit user to work with apps

remotes/1693176582716663532/tmp_refs/heads/watchparty
justcool393 2022-11-13 02:36:36 -06:00
parent 775f0d0717
commit f63237a9a2
1 changed files with 6 additions and 2 deletions

View File

@ -146,5 +146,9 @@ def feature_required(x):
return wrapper
return wrapper_maker
def ratelimit_user(limit=DEFAULT_RATELIMIT_USER):
return limiter.limit(limit, key_func=lambda:f'{SITE}-{session.get("lo_user")}')
def ratelimit_user(limit:Union[str, Callable[[], str]]=DEFAULT_RATELIMIT_USER):
'''
Ratelimits based on a user. This requires at least auth_required (or stronger) to be present,
otherwise logged out users will receive 500s
'''
return limiter.limit(limit, key_func=lambda:f'{SITE}-{g.v.id}')