From c0359719086d93ed0a4af3ea260c1f05edccbf76 Mon Sep 17 00:00:00 2001 From: virusdefender <1670873886@qq.com> Date: Sat, 12 Dec 2015 21:40:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=A4=E6=AD=A5=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=E4=B8=AD=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- account/migrations/0017_auto_20151212_2139.py | 20 +++++++++++++++++++ account/models.py | 2 +- account/views.py | 2 +- 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 account/migrations/0017_auto_20151212_2139.py diff --git a/account/migrations/0017_auto_20151212_2139.py b/account/migrations/0017_auto_20151212_2139.py new file mode 100644 index 0000000..a34d2fa --- /dev/null +++ b/account/migrations/0017_auto_20151212_2139.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9 on 2015-12-12 13:39 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('account', '0016_auto_20151211_2230'), + ] + + operations = [ + migrations.AlterField( + model_name='user', + name='tfa_token', + field=models.CharField(blank=True, max_length=40, null=True), + ), + ] diff --git a/account/models.py b/account/models.py index 98897a2..65d8745 100644 --- a/account/models.py +++ b/account/models.py @@ -42,7 +42,7 @@ class User(AbstractBaseUser): auth_token = models.CharField(max_length=40, blank=True, null=True) # 是否开启两步验证 two_factor_auth = models.BooleanField(default=False) - tfa_token = models.CharField(max_length=10, blank=True, null=True) + tfa_token = models.CharField(max_length=40, blank=True, null=True) USERNAME_FIELD = 'username' REQUIRED_FIELDS = [] diff --git a/account/views.py b/account/views.py index 8f9377b..9c41b34 100644 --- a/account/views.py +++ b/account/views.py @@ -411,7 +411,7 @@ class TwoFactorAuthAPIView(APIView): user.tfa_token = token user.save() - image = qrcode.make(OtpAuth(token).to_uri("totp", "OnlineJudgeAdmin", settings.WEBSITE_INFO["url"])) + image = qrcode.make(OtpAuth(token).to_uri("totp", settings.WEBSITE_INFO["url"], "OnlineJudgeAdmin")) buf = StringIO.StringIO() image.save(buf, 'gif')