update backend
This commit is contained in:
@ -1,8 +1,11 @@
|
||||
from fuware.core.config import get_app_settings
|
||||
from fuware.core.security.hasher import get_hasher
|
||||
from fuware.db.models import SessionLogin, User
|
||||
from fuware.schemas import UserCreate
|
||||
from sqlalchemy.orm import Session
|
||||
from uuid import uuid4
|
||||
|
||||
settings = get_app_settings()
|
||||
|
||||
class RepositoryUsers:
|
||||
def __init__(self):
|
||||
@ -33,7 +36,8 @@ class RepositoryUsers:
|
||||
|
||||
def create_session(self, db: Session, user_id: str):
|
||||
try:
|
||||
db_ss = SessionLogin(user_id=user_id)
|
||||
bhash = uuid4().hex[:10]
|
||||
db_ss = SessionLogin(session=bhash,user_id=user_id)
|
||||
db.add(db_ss)
|
||||
db.commit()
|
||||
except Exception:
|
||||
@ -50,11 +54,12 @@ class RepositoryUsers:
|
||||
return db_ss
|
||||
|
||||
def logout(self, db: Session, user_ss: str):
|
||||
print(f"Logout: {user_ss}")
|
||||
db_ss = self.sessionLogin.query.filter_by(session=user_ss).first()
|
||||
print(f"db_ss: {db_ss}")
|
||||
try:
|
||||
db.delete(db_ss)
|
||||
db.commit()
|
||||
except Exception as e:
|
||||
db.rollback()
|
||||
raise e
|
||||
pass
|
||||
|
Reference in New Issue
Block a user