mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 14:13:21 +00:00
Fix UV_endpoint auth
This commit is contained in:
parent
4759551c16
commit
86bc491df4
@ -12,10 +12,7 @@ from pedagogy.views import CanCreateUVFunctionMixin
|
|||||||
@api_view(["GET"])
|
@api_view(["GET"])
|
||||||
@renderer_classes((JSONRenderer,))
|
@renderer_classes((JSONRenderer,))
|
||||||
def uv_endpoint(request):
|
def uv_endpoint(request):
|
||||||
# is authenticated and has the right to create an UV
|
if not CanCreateUVFunctionMixin.can_create_uv(request.user):
|
||||||
if not request.user.is_authenticated or not CanCreateUVFunctionMixin.can_create_uv(
|
|
||||||
request.user
|
|
||||||
):
|
|
||||||
raise PermissionDenied
|
raise PermissionDenied
|
||||||
|
|
||||||
params = request.query_params
|
params = request.query_params
|
||||||
|
@ -38,7 +38,7 @@ def get_cached_user(request):
|
|||||||
if not hasattr(request, "_cached_user"):
|
if not hasattr(request, "_cached_user"):
|
||||||
user = get_user(request)
|
user = get_user(request)
|
||||||
if user.is_anonymous:
|
if user.is_anonymous:
|
||||||
user = AnonymousUser(request)
|
user = AnonymousUser()
|
||||||
|
|
||||||
request._cached_user = user
|
request._cached_user = user
|
||||||
|
|
||||||
|
@ -659,7 +659,7 @@ class User(AbstractBaseUser):
|
|||||||
|
|
||||||
|
|
||||||
class AnonymousUser(AuthAnonymousUser):
|
class AnonymousUser(AuthAnonymousUser):
|
||||||
def __init__(self, request):
|
def __init__(self):
|
||||||
super(AnonymousUser, self).__init__()
|
super(AnonymousUser, self).__init__()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -196,6 +196,8 @@ SASS_PRECISION = 8
|
|||||||
|
|
||||||
WSGI_APPLICATION = "sith.wsgi.application"
|
WSGI_APPLICATION = "sith.wsgi.application"
|
||||||
|
|
||||||
|
REST_FRAMEWORK = {}
|
||||||
|
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
|
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
|
||||||
@ -252,6 +254,7 @@ LOGOUT_URL = "/logout"
|
|||||||
LOGIN_REDIRECT_URL = "/"
|
LOGIN_REDIRECT_URL = "/"
|
||||||
DEFAULT_FROM_EMAIL = "bibou@git.an"
|
DEFAULT_FROM_EMAIL = "bibou@git.an"
|
||||||
SITH_COM_EMAIL = "bibou_com@git.an"
|
SITH_COM_EMAIL = "bibou_com@git.an"
|
||||||
|
REST_FRAMEWORK["UNAUTHENTICATED_USER"] = "core.models.AnonymousUser"
|
||||||
|
|
||||||
# Email
|
# Email
|
||||||
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
|
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
|
||||||
|
Loading…
Reference in New Issue
Block a user