This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import unicode_literals | |
from django.db import models | |
from django.core.mail import send_mail | |
from django.contrib.auth.models import PermissionsMixin | |
from django.contrib.auth.base_user import AbstractBaseUser | |
from django.utils.translation import ugettext_lazy as _ | |
from django.contrib.auth.base_user import BaseUserManager |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from demo.models import User | |
from rest_framework import serializers | |
import pyotp | |
class UserSerializer(serializers.ModelSerializer): | |
password = serializers.CharField(write_only=True) | |
class Meta: | |
model = User | |
fields = ('first_name', 'last_name', 'email', 'password', 'mfa_hash') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create your views here. | |
from django.contrib.auth.models import User | |
from rest_framework.views import APIView | |
from rest_framework import status | |
from .serializers import UserSerializer | |
from rest_framework.response import Response | |
from django.contrib.auth import authenticate, login | |
import pyotp | |
class Register(APIView): |