CONFIG ERROR
.fig.toml could not be parsed. Continuing with default settings.
error: could not parse configuration
--> .fig.toml
TOML parse error at line 14, column 1
|
14 | [present]
| ^^^^^^^^^
missing field `files`
help: fix the syntax shown above; default settings apply until it is valid1 10 20 30 40 50 60 70 80 901use crate::config::Config;2use crate::session::SessionStore;3use actix_web::HttpRequest;45#[must_use]6pub fn extract_pin(req: &HttpRequest) -> Option<String> {7 if let Some(s) = req8 .headers()9 .get("x-admin-pin")10 .and_then(|h| h.to_str().ok())11 {12 return Some(s.to_string());13 }1415 actix_web::web::Query::<std::collections::HashMap<String, String>>::from_query(16 req.query_string(),17 )18 .ok()19 .and_then(|q| q.get("pin").cloned())20}2122#[must_use]23pub fn is_admin(req: &HttpRequest, config: &Config, session_store: &SessionStore) -> bool {24 session_store.is_authenticated(req)25 || extract_pin(req).is_some_and(|pin| config.is_valid_pin(&pin))26}2728#[cfg(test)]29mod tests {30 use super::*;31 use actix_web::test::TestRequest;3233 #[test]34 fn test_extract_pin_header_and_query() {35 let req_hdr = TestRequest::default()36 .insert_header(("x-admin-pin", "1234"))37 .to_http_request();38 assert_eq!(extract_pin(&req_hdr), Some("1234".to_string()));3940 let req_query = TestRequest::default()41 .uri("/debug?pin=5678")42 .to_http_request();43 assert_eq!(extract_pin(&req_query), Some("5678".to_string()));4445 let req_empty = TestRequest::default().to_http_request();46 assert_eq!(extract_pin(&req_empty), None);47 }48}