修复两步验证中的错误
This commit is contained in:
20
account/migrations/0017_auto_20151212_2139.py
Normal file
20
account/migrations/0017_auto_20151212_2139.py
Normal file
@@ -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),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -42,7 +42,7 @@ class User(AbstractBaseUser):
|
|||||||
auth_token = models.CharField(max_length=40, blank=True, null=True)
|
auth_token = models.CharField(max_length=40, blank=True, null=True)
|
||||||
# 是否开启两步验证
|
# 是否开启两步验证
|
||||||
two_factor_auth = models.BooleanField(default=False)
|
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'
|
USERNAME_FIELD = 'username'
|
||||||
REQUIRED_FIELDS = []
|
REQUIRED_FIELDS = []
|
||||||
|
|||||||
@@ -411,7 +411,7 @@ class TwoFactorAuthAPIView(APIView):
|
|||||||
user.tfa_token = token
|
user.tfa_token = token
|
||||||
user.save()
|
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()
|
buf = StringIO.StringIO()
|
||||||
image.save(buf, 'gif')
|
image.save(buf, 'gif')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user