2022-10-05 12:30:21 +02:00
|
|
|
from piccolo.table import Table
|
2022-10-06 13:46:11 +02:00
|
|
|
from piccolo.columns import ForeignKey, Timestamptz, Boolean, UUID, Bytea, Integer
|
2022-10-05 12:30:21 +02:00
|
|
|
from piccolo.columns.defaults.timestamptz import TimestamptzNow
|
2022-10-06 13:46:11 +02:00
|
|
|
from enum import Enum, auto
|
2022-10-05 12:30:21 +02:00
|
|
|
|
|
|
|
|
|
|
|
from .users import User
|
|
|
|
|
|
|
|
|
2022-10-06 13:46:11 +02:00
|
|
|
class EmailVerificationType(Enum):
|
|
|
|
"""
|
|
|
|
Enumeration of email verification
|
|
|
|
types
|
|
|
|
"""
|
|
|
|
|
|
|
|
PASSWORD_RESET: int = auto()
|
|
|
|
CHANGE_EMAIL: int = auto()
|
|
|
|
OTHER: int = auto()
|
|
|
|
|
|
|
|
|
2022-10-05 12:30:21 +02:00
|
|
|
class EmailVerification(Table, tablename="email_verifications"):
|
|
|
|
id = UUID(primary_key=True, null=False)
|
|
|
|
user = ForeignKey(references=User, null=False)
|
2022-10-06 13:46:11 +02:00
|
|
|
kind = Integer(choices=EmailVerificationType)
|
2022-10-05 12:30:21 +02:00
|
|
|
creation_date = Timestamptz(default=TimestamptzNow(), null=False)
|
|
|
|
pending = Boolean(default=True, null=False)
|
|
|
|
data = Bytea(default=None, null=True)
|