Done for Login and notification system
This commit is contained in:
@ -16,19 +16,5 @@ class User(SqlAlchemyBase):
|
||||
is_admin: Mapped[bool | None] = mapped_column(Boolean, default=False)
|
||||
is_lock: Mapped[bool | None] = mapped_column(Boolean, default=False)
|
||||
|
||||
session_login = relationship("SessionLogin", back_populates="user", uselist=False)
|
||||
|
||||
def __repr__(self):
|
||||
return f"{self.__class__.__name__}, name: {self.name}, username: {self.username}"
|
||||
|
||||
class SessionLogin(SqlAlchemyBase):
|
||||
__tablename__ = 'session_login'
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
||||
session: Mapped[str] = mapped_column(String, unique=True, index=True, nullable=False)
|
||||
user_id: Mapped[str] = mapped_column(ForeignKey("users.id"), unique=True, index=True, nullable=False)
|
||||
|
||||
user = relationship("User", back_populates="session_login")
|
||||
|
||||
def __repr__(self):
|
||||
return f"{self.__class__.__name__}, session: {self.session}, user_id: {self.user_id}"
|
||||
|
@ -1,28 +0,0 @@
|
||||
from fuware.core.security import get_hasher
|
||||
|
||||
hasher = get_hasher()
|
||||
|
||||
INITIAL_DATA = {
|
||||
'users': [
|
||||
{
|
||||
'username': 'sam',
|
||||
'password': hasher.hash('admin'),
|
||||
'name': 'Sam',
|
||||
'is_admin': 1,
|
||||
'is_lock': 0,
|
||||
},
|
||||
{
|
||||
'username': 'sam1',
|
||||
'password': hasher.hash('admin'),
|
||||
'name': 'Sam1',
|
||||
'is_admin': 0,
|
||||
'is_lock': 1
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
# This method receives a table, a connection and inserts data to that table.
|
||||
def initialize_table(target, connection, **kwargs):
|
||||
tablename = str(target)
|
||||
if tablename in INITIAL_DATA and len(INITIAL_DATA[tablename]) > 0:
|
||||
connection.execute(target.insert(), INITIAL_DATA[tablename])
|
Reference in New Issue
Block a user