Miscellaneous Fixes (#1752)

* Update CHANGELOG 
* Add `registered_only` decorator
* Make team invites redirect to `/register` if you're unauthed
This commit is contained in:
Kevin Chung
2020-12-04 14:10:36 -05:00
committed by GitHub
parent d9975f307c
commit cb5ba26bdb
6 changed files with 45 additions and 5 deletions

View File

@@ -97,6 +97,29 @@ def authed_only(f):
return authed_only_wrapper
def registered_only(f):
"""
Decorator that requires the user to have a registered account
:param f:
:return:
"""
@functools.wraps(f)
def _registered_only(*args, **kwargs):
if authed():
return f(*args, **kwargs)
else:
if (
request.content_type == "application/json"
or request.accept_mimetypes.best == "text/event-stream"
):
abort(403)
else:
return redirect(url_for("auth.register", next=request.full_path))
return _registered_only
def admins_only(f):
"""
Decorator that requires the user to be authenticated and an admin