mirror of
https://github.com/aljazceru/CTFd.git
synced 2026-01-06 07:34:21 +01:00
Miscellaneous Fixes (#1752)
* Update CHANGELOG * Add `registered_only` decorator * Make team invites redirect to `/register` if you're unauthed
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user