Compare commits

...

4 Commits

3 changed files with 17 additions and 17 deletions
+4 -10
View File
@@ -10269,22 +10269,17 @@ def my_borrowed_items():
# Get current time for comparison
current_time = datetime.datetime.now()
# Check if user is admin
user_is_admin = False
if 'is_admin' in session:
user_is_admin = session['is_admin']
# Get items currently borrowed by the user (where Verfuegbar=false and User=username)
borrowed_items = list(items_collection.find({'Verfuegbar': False, 'User': username}))
borrowed_items = list(items_collection.find({'Verfuegbar': False, 'User': encrypt_text(username)}))
# Get active and planned ausleihungen for the user
active_ausleihungen = list(ausleihungen_collection.find({
'User': username,
'User': encrypt_text(username),
'Status': 'active'
}))
planned_ausleihungen = list(ausleihungen_collection.find({
'User': username,
'User': encrypt_text(username),
'Status': 'planned'
}))
@@ -10368,8 +10363,7 @@ def my_borrowed_items():
return render_template(
'my_borrowed_items.html',
items=active_items,
planned_items=planned_items,
user_is_admin=user_is_admin
planned_items=planned_items
)
+8 -3
View File
@@ -476,8 +476,13 @@ def check_nm_pwd(username, password):
user_record = users.find_one(query)
if user_record is None:
logger.warning("Kein Benutzer für %r in DB %r gefunden.", dp.encrypt_text(username), db_name)
return None
query = {'$or': [{'Username': username}, {'username': username}]}
user_record_fallback = users.find_one(query)
if user_record_fallback is None:
logger.warning("Kein Benutzer für %r in DB %r gefunden.", dp.encrypt_text(username), db_name)
return None
else:
user_record = user_record_fallback
stored_password = user_record.get('Password') or user_record.get('password')
@@ -617,7 +622,7 @@ def get_user(username):
def find_in_db(database_name):
db = client[database_name]
users = db['users']
return users.find_one({'Username': dp.encrypt_text(username)}) or users.find_one({'username': dp.encrypt_text(username)})
return users.find_one({'Username': dp.encrypt_text(username)}) or users.find_one({'username': dp.encrypt_text(username)}) or users.find_one({'username': username}) or users.find_one({'Username': username})
tenant_db, tenant_id = _resolve_request_tenant_db()
if tenant_db:
+5 -4
View File
@@ -200,6 +200,7 @@ sys.path.insert(0, "/app")
sys.path.insert(0, "/app/Web")
from Web.modules.database import settings
from pymongo import MongoClient
import Web.modules.inventarsystem.data_protection as dp
tenant_id = sys.argv[1].lower()
mode = sys.argv[2]
@@ -244,14 +245,14 @@ page_permissions = {
"manage_locations": True,
}
if db.users.count_documents({"Username": "admin"}) == 0:
if db.users.count_documents({"Username": dp.encrypt_text("admin")}) == 0:
db.users.insert_one({
"Username": "admin",
"Username": dp.encrypt_text("admin"),
"Password": hashed_pw_string,
"Admin": True,
"active_ausleihung": None,
"name": "Admin",
"last_name": "User",
"name": dp.encrypt_text("Admin"),
"last_name": dp.encrypt_text("User"),
"IsStudent": False,
"PermissionPreset": "full_access",
"ActionPermissions": action_permissions,