mirror of
https://github.com/ae-utbm/sith.git
synced 2024-12-22 15:51:19 +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"])
|
||||
@renderer_classes((JSONRenderer,))
|
||||
def uv_endpoint(request):
|
||||
# is authenticated and has the right to create an UV
|
||||
if not request.user.is_authenticated or not CanCreateUVFunctionMixin.can_create_uv(
|
||||
request.user
|
||||
):
|
||||
if not CanCreateUVFunctionMixin.can_create_uv(request.user):
|
||||
raise PermissionDenied
|
||||
|
||||
params = request.query_params
|
||||
|
@ -38,7 +38,7 @@ def get_cached_user(request):
|
||||
if not hasattr(request, "_cached_user"):
|
||||
user = get_user(request)
|
||||
if user.is_anonymous:
|
||||
user = AnonymousUser(request)
|
||||
user = AnonymousUser()
|
||||
|
||||
request._cached_user = user
|
||||
|
||||
|
@ -659,7 +659,7 @@ class User(AbstractBaseUser):
|
||||
|
||||
|
||||
class AnonymousUser(AuthAnonymousUser):
|
||||
def __init__(self, request):
|
||||
def __init__(self):
|
||||
super(AnonymousUser, self).__init__()
|
||||
|
||||
@property
|
||||
|
@ -196,6 +196,8 @@ SASS_PRECISION = 8
|
||||
|
||||
WSGI_APPLICATION = "sith.wsgi.application"
|
||||
|
||||
REST_FRAMEWORK = {}
|
||||
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
|
||||
@ -252,6 +254,7 @@ LOGOUT_URL = "/logout"
|
||||
LOGIN_REDIRECT_URL = "/"
|
||||
DEFAULT_FROM_EMAIL = "bibou@git.an"
|
||||
SITH_COM_EMAIL = "bibou_com@git.an"
|
||||
REST_FRAMEWORK["UNAUTHENTICATED_USER"] = "core.models.AnonymousUser"
|
||||
|
||||
# Email
|
||||
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
|
||||
|
Loading…
Reference in New Issue
Block a user