| | |
| | | from datetime import datetime |
| | | |
| | | # from cryptography.fernet import Fernet |
| | | from cryptography.fernet import Fernet |
| | | from sqlalchemy import Column, Integer, String, Table, ForeignKey, DateTime |
| | | from sqlalchemy.orm import relationship, backref |
| | | |
| | |
| | | user_group_table = Table('user_group', Base.metadata |
| | | , Column('user_id', Integer, ForeignKey('user.id', ondelete='CASCADE')) |
| | | , Column('group_id', Integer, ForeignKey('group.id', ondelete='CASCADE'))) |
| | | # cipher_suite = Fernet(settings.PASSWORD_KEY.encode("utf-8")) |
| | | cipher_suite = Fernet(settings.PASSWORD_KEY.encode("utf-8")) |
| | | |
| | | |
| | | class UserModel(Base): |
| | |
| | | age = Column(Integer) |
| | | created_at = Column(DateTime, default=datetime.now()) |
| | | updated_at = Column(DateTime, default=datetime.now(), onupdate=datetime.now()) |
| | | updated_at11 = Column(Integer) |
| | | |
| | | |
| | | |
| | | organizations = relationship('OrganizationModel', |
| | |
| | | 'userName': self.username, |
| | | 'loginName': self.login_name if self.login_name else "", |
| | | 'status': self.status, |
| | | 'email': self.email, |
| | | 'phone': self.phone, |
| | | 'permission':self.permission |
| | | } |
| | | |
| | | def to_json(self): |
| | |
| | | return cipher_suite.encrypt(password.encode("utf-8")).decode("utf-8") |
| | | |
| | | def decrypted_password(self): |
| | | return cipher_suite.decrypt(self.password).decode("utf-8") |
| | | return cipher_suite.decrypt(self.password).decode("utf-8") |
| | | |
| | | |
| | | |
| | | class UserModel(Base): |
| | | __tablename__ = "user_test" |
| | | id = Column(Integer, primary_key=True, index=True) |
| | | username = Column(String(255), unique=True, index=True) |
| | | hashed_password = Column(String(255)) |
| | | password = Column(String(255)) |
| | | compellation = Column(String(255), nullable=False, default="") |
| | | phone = Column(String(255), nullable=False, default="") |
| | | email = Column(String(255), nullable=False, default="") |
| | | description = Column(String(255), nullable=False, default="") |
| | | ragflow_id = Column(String(32)) |
| | | bisheng_id = Column(Integer) |