This commit is contained in:
Gvidas Juknevičius 2024-03-30 18:25:34 +02:00
parent dd9cf9b16c
commit 0f5d8615f4
Signed by: MCorange
GPG Key ID: 12B1346D720B7FBB
2 changed files with 5 additions and 1 deletions

View File

@ -104,7 +104,7 @@ impl Token {
const TOKEN_CHARSET: &'static [char] = &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '_', '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
const TOKEN_CHARSET: &'static [char] = &['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
fn generate_token(len: u8) -> String {
let mut token = String::new();

View File

@ -24,18 +24,22 @@ pub async fn handler(req: HttpRequest, token: web::Path<String>, body: Bytes, db
};
let Some(event_type) = req.headers().get("X-GitHub-Event") else {
log::debug!("No X-GitHub-Event header");
return Ok(HttpResponse::BadRequest());
};
let Ok(event_type) = event_type.to_str() else {
log::debug!("Bad X-GitHub-Event header");
return Ok(HttpResponse::BadRequest());
};
let Ok(json) = String::from_utf8(body.to_vec()) else {
log::debug!("Bad request body");
return Ok(HttpResponse::BadRequest());
};
let Ok(event) = types::Event::from_raw_json(event_type, json.clone()) else {
log::debug!("Bad request body json");
return Ok(HttpResponse::BadRequest());
};