Free chart summaries; password login off by default

- New analysis kind 'summary' (migration 0005): saving a chart queues a
  free 3-4 sentence summary written by SUMMARY_MODEL (default Sonnet
  5.5, about 1 cent; Haiku was tested too but chose weaker highlights).
  POST /v1/charts/{id}/summary returns it and re-queues a failed one.
- The chart page shows it in a "Röviden" card and polls until ready.
- PASSWORD_LOGIN (default false): register, login and password reset
  answer 403; only Google (later Apple, Facebook) logins remain.
- Prompt v2: Hungarian names for elements and modalities (an English
  "Fire" slipped into a summary); worker compare-models --summary.
- The worker also reads a lower-case openrouter_api_key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
feco
2026-11-16 17:12:17 +00:00
co-authored by Claude Opus 5.5
parent 269e3167e2
commit 450174c273
19 changed files with 339 additions and 38 deletions
+13
View File
@@ -158,12 +158,22 @@ pub struct RegisterRequest {
locale: Option<String>,
}
/// Password endpoints answer 403 while `PASSWORD_LOGIN` is off.
pub fn password_login_enabled(state: &crate::AppState) -> Result<(), ApiError> {
if state.config.password_login {
Ok(())
} else {
Err(ApiError::Forbidden("e-mail and password login is disabled; use Google, Apple or Facebook".into()))
}
}
pub async fn register(
State(state): St,
headers: HeaderMap,
jar: CookieJar,
WithRejection(Json(req), _): Body<RegisterRequest>,
) -> ApiResult<impl IntoResponse> {
password_login_enabled(&state)?;
let email = normalize_email(&req.email)?;
validate_password(&req.password)?;
let locale = validate_locale(&state, req.locale.as_deref())?;
@@ -213,6 +223,7 @@ pub async fn login(
jar: CookieJar,
WithRejection(Json(req), _): Body<LoginRequest>,
) -> ApiResult<impl IntoResponse> {
password_login_enabled(&state)?;
let invalid = || ApiError::InvalidCredentials("wrong e-mail address or password".into());
let email = normalize_email(&req.email).map_err(|_| invalid())?;
state.login_limiter.check(&email)?;
@@ -394,6 +405,7 @@ pub async fn request_password_reset(
State(state): St,
WithRejection(Json(req), _): Body<ResetRequest>,
) -> ApiResult<StatusCode> {
password_login_enabled(&state)?;
let Ok(email) = normalize_email(&req.email) else { return Ok(StatusCode::ACCEPTED) };
let mut tx = state.db.begin().await?;
let user: Option<User> = sqlx::query_as(&format!("SELECT {USER_COLUMNS} FROM users WHERE email = $1"))
@@ -422,6 +434,7 @@ pub async fn confirm_password_reset(
State(state): St,
WithRejection(Json(req), _): Body<ResetConfirmRequest>,
) -> ApiResult<StatusCode> {
password_login_enabled(&state)?;
validate_password(&req.password)?;
let hash = hash_password(req.password).await?;
let mut tx = state.db.begin().await?;