✨ Feat: [#72] 깃허브 관련 기능 구현 완료
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from django.db import models
|
||||
from django.conf import settings
|
||||
from common.models.baseModels import BaseModel
|
||||
from common.models.choiceModels import GenderChoices, CertificateCodeUseType
|
||||
from common.utils.codeManger import set_expire
|
||||
@@ -9,6 +10,9 @@ from django.contrib.auth.models import AbstractBaseUser, BaseUserManager, Permis
|
||||
|
||||
from common.models.choiceModels import NotificationType
|
||||
|
||||
from django.utils import timezone
|
||||
from datetime import timedelta
|
||||
|
||||
class UserManager(BaseUserManager):
|
||||
def create_user(self, email, password, **kwargs):
|
||||
user = self.model(email = email, **kwargs)
|
||||
@@ -72,3 +76,14 @@ class User(BaseModel, AbstractBaseUser, PermissionsMixin):
|
||||
if self.banner_image:
|
||||
self.banner_image.delete(save=False)
|
||||
super().delete(*args, **kwargs)
|
||||
|
||||
class GithubToken(models.Model):
|
||||
user = models.OneToOneField(settings.AUTH_USER_MODEL, related_name='github_token', on_delete=models.CASCADE)
|
||||
access_token = models.CharField(max_length=255, blank=True, null=True)
|
||||
refresh_token = models.CharField(max_length=255, blank=True, null=True)
|
||||
scope = models.CharField(max_length=255, blank=True)
|
||||
token_type = models.CharField(max_length=32, default='bearer')
|
||||
expires_at = models.DateTimeField(blank=True, null=True)
|
||||
|
||||
def is_expired(self) -> bool:
|
||||
return self.expires_at and timezone.now() >= self.expires_at
|
||||
Reference in New Issue
Block a user