From 4076b99ff73aa4e8014e04d9b485092d72dbe9a7 Mon Sep 17 00:00:00 2001 From: liangliang Date: Fri, 29 Sep 2017 23:35:04 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=B8=85=E9=99=A4session?= =?UTF-8?q?=E6=96=87=E4=BB=B6=EF=BC=8C=E4=BF=AE=E5=A4=8D=E5=88=9B=E5=BB=BA?= =?UTF-8?q?oauth=E7=94=A8=E6=88=B7=E5=90=8D=E8=BF=87=E9=95=BFbug=20Fix=20#?= =?UTF-8?q?34?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- oauth/views.py | 6 +++--- servermanager/robot.py | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/oauth/views.py b/oauth/views.py index f3e8a9e..678e7bc 100644 --- a/oauth/views.py +++ b/oauth/views.py @@ -53,7 +53,7 @@ def authorize(request): if user: if not user.nikename: import datetime - user.nikename = "djangoblog" + datetime.datetime.now().strftime('%y%m%d%I') + user.nikename = "djangoblog" + datetime.datetime.now().strftime('%y%m%d%I%M%S') try: token = user.token user = OAuthUser.objects.get(type=type, openid=user.openid) @@ -72,7 +72,7 @@ def authorize(request): result = get_user_model().objects.get_or_create(email=user.email) author = result[0] if result[1]: - author.username = user.nikename + '_' + str(user.openid) + author.username = user.nikename author.save() user.author = author @@ -103,7 +103,7 @@ def emailconfirm(request, id, sign): result = get_user_model().objects.get_or_create(email=oauthuser.email) author = result[0] if result[1]: - author.username = oauthuser.nikename + '_' + str(oauthuser.openid) + author.username = oauthuser.nikename author.save() """ if oauthuser.email and author.email: diff --git a/servermanager/robot.py b/servermanager/robot.py index f7ed226..2865ba1 100644 --- a/servermanager/robot.py +++ b/servermanager/robot.py @@ -32,7 +32,11 @@ if memstorage.is_available: robot.config['SESSION_STORAGE'] = memstorage else: from werobot.session.filestorage import FileStorage + import os + from django.conf import settings + if os.path.exists(os.path.join(settings.BASE_DIR, 'werobot_session')): + os.remove(os.path.join(settings.BASE_DIR, 'werobot_session')) robot.config['SESSION_STORAGE'] = FileStorage(filename='werobot_session') blogapi = BlogApi() tuling = TuLing()