Fix UV_endpoint auth

This commit is contained in:
tleb 2019-10-20 18:26:11 +02:00
parent 4759551c16
commit 86bc491df4
4 changed files with 6 additions and 6 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"