1
0
Fork 0
mirror of https://github.com/SinTan1729/chhoto-url synced 2025-02-05 13:52:33 -06:00

Improved API error codes

This commit is contained in:
Solninja A 2025-01-01 19:08:35 +10:00
parent 818dadb84f
commit 9a0cdec646

View file

@ -34,7 +34,7 @@ pub fn is_api_ok(http: HttpRequest) -> Response {
if let Some(header) = auth::api_header(&http) { if let Some(header) = auth::api_header(&http) {
// If the header is correct // If the header is correct
if auth::validate_key(header.to_string()) { if auth::validate_key(header.to_string()) {
Response { success: true, error: false, reason: "".to_string(), pass: false } Response { success: true, error: false, reason: "Correct API key".to_string(), pass: false }
} else { } else {
Response { success: false, error: true, reason: "Incorrect API key".to_string(), pass: false } Response { success: false, error: true, reason: "Incorrect API key".to_string(), pass: false }
} }
@ -46,7 +46,7 @@ pub fn is_api_ok(http: HttpRequest) -> Response {
} else { } else {
// If the API key isn't set, but an API Key header is provided // If the API key isn't set, but an API Key header is provided
if auth::api_header(&http).is_some() { if auth::api_header(&http).is_some() {
Response {success: false, error: true, reason: "API key access was attempted, but no API key is configured".to_string(), pass: false} Response {success: false, error: true, reason: "An API key was provided, but the 'api_key' environment variable is not configured in the Chhoto URL instance".to_string(), pass: false}
} else { } else {
Response {success: false, error: false, reason: "".to_string(), pass: true} Response {success: false, error: false, reason: "".to_string(), pass: true}
} }