mirror of
https://github.com/fergalmoran/dss.api.git
synced 2025-12-26 19:28:23 +00:00
Fixed comments bug
This commit is contained in:
@@ -16,6 +16,12 @@ from social.apps.django_app.utils import psa
|
||||
|
||||
logger = logging.getLogger('dss')
|
||||
|
||||
BACKENDS = {
|
||||
'google': 'google-oauth2',
|
||||
'facebook': 'facebook',
|
||||
'twitter': 'twitter'
|
||||
}
|
||||
|
||||
|
||||
@psa()
|
||||
def auth_by_token(request, backend):
|
||||
@@ -31,7 +37,7 @@ class SocialLoginHandler(APIView):
|
||||
|
||||
def post(self, request, format=None):
|
||||
auth_token = request.data.get('access_token', None)
|
||||
backend = request.data.get('backend', None)
|
||||
backend = BACKENDS.get(request.data.get('backend', None), 'facebook')
|
||||
|
||||
if auth_token and backend:
|
||||
try:
|
||||
|
||||
@@ -402,7 +402,7 @@ class CommentSerializer(serializers.HyperlinkedModelSerializer):
|
||||
|
||||
def get_can_edit(self, obj):
|
||||
user = self.context['request'].user
|
||||
if user is not None and user.is_authenticated():
|
||||
if user is not None and obj.user is not None and user.is_authenticated():
|
||||
return user.is_staff or obj.user.id == user.userprofile.id
|
||||
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user