Skip to content

将用户头像保存本地 #138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 18, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions oauth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
from django.core.exceptions import ObjectDoesNotExist
from django.http import HttpResponseForbidden
from .oauthmanager import get_manager_by_type
import logging

logger = logging.getLogger(__name__)


def oauthlogin(request):
Expand Down Expand Up @@ -48,10 +51,8 @@ def authorize(request):
if not rsp:
return HttpResponseRedirect(manager.get_authorization_url(nexturl))
user = manager.get_oauth_userinfo()

logger.info('user:' + user.nikename)
if user:
if user.picture:
user.picture = save_user_avatar(user.picture)
if not user.nikename:
import datetime
user.nikename = "djangoblog" + datetime.datetime.now().strftime('%y%m%d%I%M%S')
Expand All @@ -60,6 +61,8 @@ def authorize(request):
except ObjectDoesNotExist:
pass
# facebook的token过长
if user.picture:
user.picture = save_user_avatar(user.picture)
if type == 'facebook':
user.token = ''
email = user.email
Expand Down