@ -4,7 +4,7 @@ from typing import Optional, cast
from flask_login import UserMixin # type: ignore
from flask_login import UserMixin # type: ignore
from sqlalchemy import func
from sqlalchemy import func
from sqlalchemy . orm import Mapped , mapped_column
from sqlalchemy . orm import Mapped , mapped_column , reconstructor
from models . base import Base
from models . base import Base
@ -81,8 +81,6 @@ class AccountStatus(enum.StrEnum):
class Account ( UserMixin , Base ) :
class Account ( UserMixin , Base ) :
role : Optional [ " TenantAccountRole " ] = None
_current_tenant : Optional [ " Tenant " ] = None
__tablename__ = " accounts "
__tablename__ = " accounts "
__table_args__ = ( db . PrimaryKeyConstraint ( " id " , name = " account_pkey " ) , db . Index ( " account_email_idx " , " email " ) )
__table_args__ = ( db . PrimaryKeyConstraint ( " id " , name = " account_pkey " ) , db . Index ( " account_email_idx " , " email " ) )
@ -103,6 +101,11 @@ class Account(UserMixin, Base):
created_at = db . Column ( db . DateTime , nullable = False , server_default = func . current_timestamp ( ) )
created_at = db . Column ( db . DateTime , nullable = False , server_default = func . current_timestamp ( ) )
updated_at = db . Column ( db . DateTime , nullable = False , server_default = func . current_timestamp ( ) )
updated_at = db . Column ( db . DateTime , nullable = False , server_default = func . current_timestamp ( ) )
@reconstructor
def init_on_load ( self ) :
self . role : Optional [ TenantAccountRole ] = None
self . _current_tenant : Optional [ Tenant ] = None
@property
@property
def is_password_set ( self ) :
def is_password_set ( self ) :
return self . password is not None
return self . password is not None