Sales Trainer v0.1: corporate sales-training simulator (Flask+Vue, 15 personas, chat simulator, judge, analytics)
- Auth/roles (no self-reg), admin user provision, JWT - Analyze: sales kit + initial pain-fit from form/upload - Persona generator: 15 personas (5/tier) w/ pain variety, negotiation, init mode, channel, latent/revealable, wrong_text special - Chat simulator: per-mode initiation, one-shot, hidden signals, judge-LLM debrief+coaching - Trainee loop: win/lose board, weak-areas, user-generated personas - Admin analytics; EN+TH Vue SPA served by Flask - Deploy: Dockerfile, docker-compose, README, eng-log + HANDOFF - Tests (mock LLM): m0/m1/routes/e2e all pass
This commit is contained in:
36
backend/app/api/auth_routes.py
Normal file
36
backend/app/api/auth_routes.py
Normal file
@@ -0,0 +1,36 @@
|
||||
"""Auth routes: login + current user. No self-registration."""
|
||||
from __future__ import annotations
|
||||
|
||||
from flask import Blueprint, jsonify, request
|
||||
|
||||
from ..auth.users import AuthError
|
||||
from .helpers import ApiError, current_user, require_auth
|
||||
|
||||
auth_bp = Blueprint("auth", __name__)
|
||||
|
||||
|
||||
def _store():
|
||||
from flask import current_app
|
||||
|
||||
return current_app.extensions["user_store"]
|
||||
|
||||
|
||||
@auth_bp.post("/login")
|
||||
def login():
|
||||
data = request.get_json(silent=True) or {}
|
||||
email = (data.get("email") or "").strip().lower()
|
||||
password = data.get("password") or ""
|
||||
if not email or not password:
|
||||
raise ApiError("email and password are required")
|
||||
try:
|
||||
user = _store().verify(email, password)
|
||||
token = _store().issue_token(user)
|
||||
except AuthError as exc:
|
||||
raise ApiError(str(exc), 401)
|
||||
return jsonify({"token": token, "user": _store().public_user(user)})
|
||||
|
||||
|
||||
@auth_bp.get("/me")
|
||||
@require_auth
|
||||
def me():
|
||||
return jsonify({"user": _store().public_user(current_user())})
|
||||
Reference in New Issue
Block a user