sio-2425/delivery2/server/models/session.py

24 lines
1.1 KiB
Python

from database import db_connection
class Session(db_connection.Model):
__tablename__ = 'sessions'
id = db_connection.Column(db_connection.Integer, primary_key=True)
user_id = db_connection.Column(db_connection.Integer, db_connection.ForeignKey('users.id'))
org_id = db_connection.Column(db_connection.Integer, db_connection.ForeignKey('organizations.id'))
token = db_connection.Column(db_connection.String(255), unique=True)
roles = db_connection.Column(db_connection.JSON, default=list)
created_at = db_connection.Column(db_connection.DateTime, server_default=db_connection.func.now())
updated_at = db_connection.Column(db_connection.DateTime, server_default=db_connection.func.now(), server_onupdate=db_connection.func.now())
challenge = db_connection.Column(db_connection.String(255), unique=True)
verified = db_connection.Column(db_connection.Boolean, default=False)
def to_dict(self):
return {
"id": self.id,
"user_id": self.user_id,
"org_id": self.org_id,
"token": self.token,
"verified": self.verified
}