Skip to content

Commit

Permalink
add email domains model in db
Browse files Browse the repository at this point in the history
  • Loading branch information
asp345 committed Feb 6, 2025
1 parent fa3848c commit e98f88e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
9 changes: 9 additions & 0 deletions oauth/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,12 @@ def __str__(self):

class Meta:
db_table = 'oauth_info'

class EmailDomain(models.Model):
domain = models.CharField(max_length=255)

def __str__(self):
return self.domain

class Meta:
db_table = 'email_domain'
5 changes: 3 additions & 2 deletions oauth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


from django.conf import settings
from oauth.models import OauthInfo
from oauth.models import OauthInfo, EmailDomain
from rest_framework import status
from rest_framework.response import Response
from rest_framework.views import APIView
Expand Down Expand Up @@ -62,7 +62,8 @@ def get(self, request, *args, **kwargs):
email = userinfo.get("email")
sub = userinfo.get("id")

email_domains = ["@wemade.com", "@wemadeconnect.com", "@gmail.com", "@snu.ac.kr"]
# @gmail.com and @snu.ac.kr are allowed for testing
email_domains = ["@wemade.com", "@gmail.com", "@snu.ac.kr"] + list(EmailDomain.objects.values_list("domain", flat=True))
if not email or not any(email.endswith(domain) for domain in email_domains):
return Response({"error": "Email not provided by Corporation"}, status=status.HTTP_400_BAD_REQUEST)

Expand Down

0 comments on commit e98f88e

Please sign in to comment.