GET method for user account API.
This commit is contained in:
@@ -11,6 +11,7 @@ from rest_framework.authentication import OAuth2Authentication, SessionAuthentic
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from xmodule.modulestore.django import modulestore
|
||||
from courseware.courses import get_course_with_access
|
||||
from openedx.core.lib.api.permissions import IsUserInUrl
|
||||
|
||||
|
||||
def mobile_course_access(depth=0, verify_enrolled=True):
|
||||
@@ -43,13 +44,6 @@ def mobile_view(is_user=False):
|
||||
"""
|
||||
Function and class decorator that abstracts the authentication and permission checks for mobile api views.
|
||||
"""
|
||||
class IsUser(permissions.BasePermission):
|
||||
"""
|
||||
Permission that checks to see if the request user matches the user in the URL.
|
||||
"""
|
||||
def has_permission(self, request, view):
|
||||
return request.user.username == request.parser_context.get('kwargs', {}).get('username', None)
|
||||
|
||||
def _decorator(func_or_class):
|
||||
"""
|
||||
Requires either OAuth2 or Session-based authentication.
|
||||
@@ -58,6 +52,6 @@ def mobile_view(is_user=False):
|
||||
func_or_class.authentication_classes = (OAuth2Authentication, SessionAuthentication)
|
||||
func_or_class.permission_classes = (permissions.IsAuthenticated,)
|
||||
if is_user:
|
||||
func_or_class.permission_classes += (IsUser,)
|
||||
func_or_class.permission_classes += (IsUserInUrl,)
|
||||
return func_or_class
|
||||
return _decorator
|
||||
|
||||
Reference in New Issue
Block a user