Skip to content
Snippets Groups Projects
Commit 0eb35060 authored by Benjamin Zagorsky's avatar Benjamin Zagorsky
Browse files

changes failure on request.session.get('LTI_LAUNCH', None) returning None from...

changes failure on request.session.get('LTI_LAUNCH', None) returning None from an AttributeError to an ImproperlyConfigured exception
parent a2de0341
No related branches found
No related tags found
No related merge requests found
from functools import wraps
from django.core.exceptions import PermissionDenied
from django.core.exceptions import PermissionDenied, ImproperlyConfigured
from django.utils.decorators import available_attrs
from django.shortcuts import redirect
from django.core.urlresolvers import reverse_lazy
......@@ -15,6 +15,10 @@ def lti_role_required(allowed_roles, redirect_url=reverse_lazy('not_authorized')
allowed = allowed_roles
lti_params = request.session.get('LTI_LAUNCH', None)
if lti_params is None:
# If this is raised, then likely the project doesn't have
# the correct settings or is being run outside of an lti context
raise ImproperlyConfigured("No LTI_LAUNCH vale found in session")
user_roles = lti_params.get('roles', [])
if set(allowed) & set(user_roles):
return view_func(request, *args, **kwargs)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment