1
0
mirror of https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git synced 2025-08-14 00:25:46 +02:00
This commit is contained in:
MoonTestUse1
2024-12-24 20:06:57 +06:00
parent b34ca1c2ce
commit 8a5fdbd674
2 changed files with 26 additions and 15 deletions

View File

@@ -4,14 +4,19 @@ from ..utils.auth import verify_password
def authenticate_employee(db: Session, last_name: str, password: str):
employee = (
db.query(tables.Employee).filter(tables.Employee.last_name == last_name).first()
)
employee = db.query(tables.Employee).filter(tables.Employee.last_name == last_name).first()
if not employee:
return None
if not verify_password(password, employee.password):
return None
return employee
return {
"id": employee.id,
"firstName": employee.first_name,
"lastName": employee.last_name,
"department": employee.department,
"office": employee.office,
"createdAt": employee.created_at
}
def authenticate_admin(db: Session, username: str, password: str):