opencode ergebnis V0.1
This commit is contained in:
1 parent
61d86a3d83
commit
7e498ebc3f
71 files changed
+28982
-46
No files matched your search
@@ -0,0 +1,4 @@
|
||||
from .init import api_init_bp
|
||||
from .auth import api_auth_bp
|
||||
|
||||
api_bp = api_init_bp
|
||||
@@ -0,0 +1,27 @@
|
||||
"""
|
||||
API Auth Endpunkte
|
||||
"""
|
||||
from flask import Blueprint, jsonify, g, session
|
||||
from cmbnet.auth import login_required
|
||||
from cmbnet.db import get_db
|
||||
import secrets
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
api_auth_bp = Blueprint('api_auth', __name__)
|
||||
|
||||
|
||||
@api_auth_bp.route('/auth/ws-token', methods=['GET', 'POST'])
|
||||
@login_required
|
||||
def ws_token(**kwargs):
|
||||
"""Erzeugt ein Zugriffstoken für WebSocket-Authentifizierung"""
|
||||
db = get_db()
|
||||
token = secrets.token_urlsafe(32)
|
||||
expires_at = datetime.now() + timedelta(hours=1)
|
||||
|
||||
db.execute(
|
||||
'INSERT INTO ws_tokens (tenant_id, account_id, token, expires_at) VALUES (?, ?, ?, ?)',
|
||||
(g.tenant_id, session['account_id'], token, expires_at)
|
||||
)
|
||||
db.commit()
|
||||
|
||||
return jsonify({'token': token})
|
||||
@@ -0,0 +1,26 @@
|
||||
"""
|
||||
API Endpunkte für Initialdaten
|
||||
"""
|
||||
from flask import Blueprint, jsonify, g
|
||||
from cmbnet.auth import login_required
|
||||
from cmbnet.services.streets_service import StreetsService
|
||||
from cmbnet.services.groups_service import GroupsService
|
||||
|
||||
api_init_bp = Blueprint('api_init', __name__)
|
||||
|
||||
|
||||
@api_init_bp.route('/init/streets')
|
||||
@login_required
|
||||
def init_streets(**kwargs):
|
||||
"""Liefert alle Straßen für den Initialload"""
|
||||
streets = StreetsService.get_all_for_init(g.tenant_id)
|
||||
return jsonify(streets)
|
||||
|
||||
|
||||
@api_init_bp.route('/init/groups')
|
||||
@login_required
|
||||
def init_groups(**kwargs):
|
||||
"""Liefert alle Gruppen für den Initialload (aus Cache)"""
|
||||
groups_dict = GroupsService.get_all(g.tenant_id)
|
||||
groups_list = list(groups_dict.values())
|
||||
return jsonify(groups_list)
|
||||
Reference in new issue
Block a user