fix: key_type stored as bare string instead of JSON string

**Problem**:
- key_type stored as "user" (with quotes, len=6)
- Future WHERE key_type = 'user' would silently fail

**Solution**:
- Added ApiKeyType::as_str() method
- Returns bare string: "system", "user", etc.
- handlers.rs:437 now uses as_str() instead of serde_json::to_string()

**Impact**:
- Existing test keys in test DBs can be safely ignored
- Production DB has no api_keys yet
- No code relies on JSON-quoted format
This commit is contained in:
Accusys
2026-10-05 03:01:42 +08:00
parent 0d5f5f4b22
commit 3ef6ccee7f
+10
View File
@@ -16,6 +16,16 @@ pub enum ApiKeyType {
}
impl ApiKeyType {
pub fn as_str(&self) -> &'static str {
match self {
ApiKeyType::System => "system",
ApiKeyType::User => "user",
ApiKeyType::Service => "service",
ApiKeyType::Integration => "integration",
ApiKeyType::Emergency => "emergency",
}
}
pub fn prefix(&self) -> &'static str {
match self {
ApiKeyType::System => "msys_",