nice francis

This commit is contained in:
Maxime Bloch 2020-07-22 05:48:19 +02:00
parent 688f303978
commit acbc5deb69

View file

@ -6,6 +6,7 @@ from django.contrib.auth import login
from django.http.request import HttpRequest
from django.shortcuts import redirect
import users
from users.models import CustomUser
logger = logging.getLogger(__file__)
@ -38,7 +39,6 @@ def register_callback(req: HttpRequest):
try:
if response.status_code == 200:
json: dict = response.json()
csrftoken = response.cookies['csrftoken']
print(response.cookies)
# TODO: maybe later do something with the refresh token.
user: dict = user_info(json['access_token'], csrftoken)
@ -59,12 +59,13 @@ def register_callback(req: HttpRequest):
def validate_user(zeus_id, username) -> CustomUser:
try:
user = CustomUser.objects.get(zeus_id=zeus_id)
if user is None:
return CustomUser.objects.create_user(zeus_id, username)
user.username = username
user.save()
return user
except users.models.CustomUser.DoesNotExist as e:
return CustomUser.objects.create_user(zeus_id, username)
def user_info(access_token, csrftoken):