Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 10e7f3e70d | |||
| e8f0d4bdc5 |
@@ -229,7 +229,7 @@
|
||||
<div class="container">
|
||||
<div class="student-card-header">
|
||||
<div>
|
||||
<h1>📚 Bibliotheksausweise (Bibliotek)</h1>
|
||||
<h1>📚 Bibliotheksausweise (Bibliothek)</h1>
|
||||
</div>
|
||||
<div class="export-buttons">
|
||||
<a href="{{ url_for('student_card_barcode_download') }}" class="btn-print" style="background: #28a745;">📥 Alle Ausweise (PDF)</a>
|
||||
|
||||
@@ -280,7 +280,7 @@
|
||||
<button type="button" data-target-step="0">1. Startseite</button>
|
||||
<button type="button" data-target-step="1">2. {{ 'Artikel erfassen' if is_admin else 'Artikel finden' }}</button>
|
||||
{% if library_module_enabled %}
|
||||
<button type="button" data-target-step="2">3. Bibliotek</button>
|
||||
<button type="button" data-target-step="2">3. Bibliothek</button>
|
||||
{% endif %}
|
||||
<button type="button" data-target-step="{{ '3' if library_module_enabled else '2' }}">4. Alltag</button>
|
||||
</div>
|
||||
@@ -341,7 +341,7 @@
|
||||
|
||||
{% if library_module_enabled %}
|
||||
<article class="workflow-step" data-step-index="2" data-step-key="library">
|
||||
<h3>Bibliotek-Bereich</h3>
|
||||
<h3>Bibliothek-Bereich</h3>
|
||||
<p>Dieser Bereich ist speziell für Bücher und Medienausleihe.</p>
|
||||
<ul>
|
||||
{% if is_admin %}
|
||||
@@ -358,7 +358,7 @@
|
||||
</ul>
|
||||
|
||||
<div class="tutorial-actions">
|
||||
<a class="btn btn-outline-primary btn-sm" href="{{ url_for('library_view') }}">Zur Bibliotek</a>
|
||||
<a class="btn btn-outline-primary btn-sm" href="{{ url_for('library_view') }}">Zur Bibliothek</a>
|
||||
{% if is_admin %}
|
||||
<a class="btn btn-outline-secondary btn-sm" href="{{ url_for('library_loans_admin') }}">Ausleihen ansehen</a>
|
||||
{% endif %}
|
||||
|
||||
+35
-17
@@ -166,6 +166,11 @@ def _find_registered_tenant_id(candidate):
|
||||
return None
|
||||
|
||||
|
||||
def _resolve_registered_tenant_id(candidate):
|
||||
"""Return the canonical registered tenant id for a candidate, or None."""
|
||||
return _find_registered_tenant_id(candidate)
|
||||
|
||||
|
||||
def _is_ip_host(hostname):
|
||||
hostname = str(hostname or '').strip()
|
||||
if not hostname:
|
||||
@@ -185,6 +190,8 @@ def get_tenant_config(tenant_id=None):
|
||||
ctx = get_tenant_context()
|
||||
tenant_id = ctx.tenant_id if ctx and ctx.tenant_id else 'default'
|
||||
|
||||
tenant_id = _resolve_registered_tenant_id(tenant_id) or tenant_id
|
||||
|
||||
if tenant_id in TENANT_REGISTRY:
|
||||
return TENANT_REGISTRY[tenant_id] or {}
|
||||
|
||||
@@ -481,20 +488,22 @@ class TenantContext:
|
||||
or request.args.get('tenantId', '').strip()
|
||||
)
|
||||
if tenant_from_query:
|
||||
matched_tenant = _find_registered_tenant_id(tenant_from_query) or tenant_from_query
|
||||
self.tenant_id = matched_tenant
|
||||
self.config = get_tenant_config(matched_tenant)
|
||||
session['tenant_id'] = matched_tenant
|
||||
return self._get_db_name(matched_tenant)
|
||||
matched_tenant = _resolve_registered_tenant_id(tenant_from_query)
|
||||
if matched_tenant:
|
||||
self.tenant_id = matched_tenant
|
||||
self.config = get_tenant_config(matched_tenant)
|
||||
session['tenant_id'] = matched_tenant
|
||||
return self._get_db_name(matched_tenant)
|
||||
|
||||
# Priority 1: X-Tenant-ID header (for testing/internal APIs)
|
||||
tenant_from_header = request.headers.get('X-Tenant-ID', '').strip()
|
||||
if tenant_from_header:
|
||||
matched_tenant = _find_registered_tenant_id(tenant_from_header) or tenant_from_header
|
||||
self.tenant_id = matched_tenant
|
||||
self.config = get_tenant_config(matched_tenant)
|
||||
session['tenant_id'] = matched_tenant
|
||||
return self._get_db_name(matched_tenant)
|
||||
matched_tenant = _resolve_registered_tenant_id(tenant_from_header)
|
||||
if matched_tenant:
|
||||
self.tenant_id = matched_tenant
|
||||
self.config = get_tenant_config(matched_tenant)
|
||||
session['tenant_id'] = matched_tenant
|
||||
return self._get_db_name(matched_tenant)
|
||||
|
||||
# Priority 2: Port/host based tenant mapping
|
||||
host_candidates = _request_host_candidates()
|
||||
@@ -544,11 +553,11 @@ class TenantContext:
|
||||
if len(parts) >= 2:
|
||||
potential_subdomain = parts[0]
|
||||
if potential_subdomain not in ('www', 'api', 'admin', 'app', 'mail'):
|
||||
matched_tenant = _find_registered_tenant_id(potential_subdomain)
|
||||
matched_tenant = _resolve_registered_tenant_id(potential_subdomain)
|
||||
if not matched_tenant and potential_subdomain.startswith('school'):
|
||||
matched_tenant = _find_registered_tenant_id('schule' + potential_subdomain[len('school'):])
|
||||
matched_tenant = _resolve_registered_tenant_id('schule' + potential_subdomain[len('school'):])
|
||||
elif not matched_tenant and potential_subdomain.startswith('schule'):
|
||||
matched_tenant = _find_registered_tenant_id('school' + potential_subdomain[len('schule'):])
|
||||
matched_tenant = _resolve_registered_tenant_id('school' + potential_subdomain[len('schule'):])
|
||||
if matched_tenant:
|
||||
self.subdomain = potential_subdomain
|
||||
self.tenant_id = matched_tenant
|
||||
@@ -565,12 +574,21 @@ class TenantContext:
|
||||
# Priority 4: sticky tenant from the authenticated session
|
||||
session_tenant = session.get('tenant_id', '').strip() if session.get('tenant_id') else ''
|
||||
if session_tenant:
|
||||
self.tenant_id = session_tenant
|
||||
self.config = get_tenant_config(session_tenant)
|
||||
matched_tenant = _resolve_registered_tenant_id(session_tenant)
|
||||
if matched_tenant:
|
||||
self.tenant_id = matched_tenant
|
||||
self.config = get_tenant_config(matched_tenant)
|
||||
session['tenant_id'] = matched_tenant
|
||||
logger.info(
|
||||
f"Tenant resolution by session: host={primary_host} tenant={matched_tenant} config={self.config}"
|
||||
)
|
||||
return self._get_db_name(matched_tenant)
|
||||
session.pop('tenant_id', None)
|
||||
logger.info(
|
||||
f"Tenant resolution by session: host={primary_host} tenant={session_tenant} config={self.config}"
|
||||
"Discarded stale tenant session reference: host=%s tenant=%s",
|
||||
primary_host,
|
||||
session_tenant,
|
||||
)
|
||||
return self._get_db_name(session_tenant)
|
||||
|
||||
# Fallback to default tenant if no tenant identifier found.
|
||||
# If no explicit 'default' tenant config exists, use configured MongoDB DB.
|
||||
|
||||
Reference in New Issue
Block a user