Fakultas Ilmu Komputer UI

Commit c59bb733 authored by Yumna Pratista Tastaftian's avatar Yumna Pratista Tastaftian
Browse files

Merge branch 'testinggoat/ex8' into 'master'

Testinggoat/ex8

See merge request !8
parents efa00ed2 02842153
Pipeline #26090 passed with stages
in 5 minutes and 52 seconds
This diff is collapsed.
import sys
from accounts.models import ListUser, Token
from accounts.models import Token, User
class PasswordlessAuthenticationBackend(object):
def authenticate(self,request, uid):
print('uid', uid, file=sys.stderr)
if not Token.objects.filter(uid=uid).exists():
print('no token found', file=sys.stderr)
return None
token = Token.objects.get(uid=uid)
print('got token', file=sys.stderr)
def authenticate(self, request, uid):
print(uid + " authenticate")
try:
user = ListUser.objects.get(email=token.email)
print('got user', file=sys.stderr)
return user
except ListUser.DoesNotExist:
print('new user', file=sys.stderr)
return ListUser.objects.create(email=token.email)
print(uid + " USER EXISTS")
token = Token.objects.get(uid=uid)
return User.objects.get(email=token.email)
except User.DoesNotExist:
print(uid + " USER NOT EXISTS")
return User.objects.create(email=token.email)
except Token.DoesNotExist:
print(uid + " TOKEN NOT EXISTS")
return None
def get_user(self, email):
return ListUser.objects.get(email=email)
\ No newline at end of file
try:
return User.objects.get(email=email)
except User.DoesNotExist:
return None
from django.db import models
import uuid
from django.contrib import auth
auth.signals.user_logged_in.disconnect(auth.models.update_last_login)
class User(models.Model):
email = models.EmailField(primary_key = True)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment