[Multi-User]: Part 0 - Add support for logging in with Google (#487)

* Add concept of user authentication to the request session via GoogleUser
This commit is contained in:
sabaimran
2023-10-14 19:39:13 -07:00
committed by GitHub
parent 4a5ed7f06c
commit c125995d94
24 changed files with 702 additions and 17 deletions

View File

@@ -0,0 +1,53 @@
import uuid
from django.db import models
from django.contrib.auth.models import AbstractUser
class KhojUser(AbstractUser):
uuid = models.UUIDField(models.UUIDField(default=uuid.uuid4, editable=False))
class GoogleUser(models.Model):
user = models.OneToOneField(KhojUser, on_delete=models.CASCADE)
sub = models.CharField(max_length=200)
azp = models.CharField(max_length=200)
email = models.CharField(max_length=200)
name = models.CharField(max_length=200)
given_name = models.CharField(max_length=200)
family_name = models.CharField(max_length=200)
picture = models.CharField(max_length=200)
locale = models.CharField(max_length=200)
def __str__(self):
return self.name
class Configuration(models.Model):
user = models.OneToOneField(KhojUser, on_delete=models.CASCADE)
class NotionConfig(models.Model):
token = models.CharField(max_length=200)
compressed_jsonl = models.CharField(max_length=300)
embeddings_file = models.CharField(max_length=300)
config = models.OneToOneField(Configuration, on_delete=models.CASCADE)
class GithubConfig(models.Model):
pat_token = models.CharField(max_length=200)
compressed_jsonl = models.CharField(max_length=300)
embeddings_file = models.CharField(max_length=300)
config = models.OneToOneField(Configuration, on_delete=models.CASCADE)
class GithubRepoConfig(models.Model):
name = models.CharField(max_length=200)
owner = models.CharField(max_length=200)
branch = models.CharField(max_length=200)
github_config = models.ForeignKey(GithubConfig, on_delete=models.CASCADE)
class ConversationProcessorConfig(models.Model):
conversation = models.JSONField()
enable_offline_chat = models.BooleanField(default=False)