20 lines
632 B
Python
20 lines
632 B
Python
import hashlib
|
|
|
|
from sqlalchemy import Boolean, Column, Integer, String
|
|
from sqlalchemy.orm import relationship
|
|
from functions.admin.models.database import Base
|
|
|
|
class User(Base):
|
|
__tablename__ = "users"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
username = Column(String(50), unique=True)
|
|
email = Column(String(255), unique=True)
|
|
password_hash = Column(String(255))
|
|
is_active = Column(Boolean(), default=True)
|
|
|
|
tokens = relationship("Token", back_populates="user")
|
|
|
|
def check_password(self, password: str):
|
|
return self.password_hash == hashlib.sha384(password.encode()).hexdigest()
|