From ca5e7da4cc06c23ad62e3e0e77582b8dafcbf3f7 Mon Sep 17 00:00:00 2001 From: Ivlev Denis Date: Fri, 2 Feb 2018 20:57:01 +0300 Subject: [PATCH] Fix if user login to site with FB and not have photo then set photo from FB --- apps/auth/views.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/auth/views.py b/apps/auth/views.py index 85aabd8a..3d4ba19d 100644 --- a/apps/auth/views.py +++ b/apps/auth/views.py @@ -169,5 +169,9 @@ class FacebookLoginOrRegistration(View): login(requests, user=user) return JsonResponse({"success": True}) else: + if not user.photo and photo_data: + photo = ContentFile(photo_data) + fname = str(fb_id) + '.jpg' + user.photo.save(fname, photo, save=True) login(requests, user=user) return JsonResponse({"success": True})