Commit 36f0e93b authored by spookydonut's avatar spookydonut

hopefully fix compile errors

parent e398ce35
Pipeline #151 failed with stages
......@@ -4,6 +4,7 @@ extern crate lazy_static;
#[macro_use]
extern crate log;
extern crate simplelog;
#[macro_use] extern crate guard;
use simplelog::*;
use std::fs::{read_to_string, File};
......
......@@ -4,7 +4,6 @@ use openssl::symm::{decrypt, encrypt, Cipher};
use rand::Rng;
use serenity::model::user::User;
use std::str;
#[macro_use] extern crate guard;
lazy_static! {
static ref KEY: [u8; 32] = rand::thread_rng().gen::<[u8; 32]>();
......@@ -21,15 +20,15 @@ fn text_decrypt(ciphertext: &str) -> Option<String> {
let iv: &[u8; 16] = &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
guard!(let Ok(cipher_vec) = base64::decode(ciphertext) else {
warn!("Unable to decode base64 text");
None
return None
});
guard!(let Ok(decrypted_vec) = decrypt(*CIPHER, &*KEY, Some(iv), &cipher_vec) else {
warn!("Text decryption failed");
None
return None
});
guard!(let Ok(decrypted_token) = str::from_utf8(decrypted_vec.as_slice()) else {
warn!("Invalid utf8 in text");
None
return None
});
Some(decrypted_token.to_owned())
}
......@@ -61,7 +60,7 @@ impl std::fmt::Display for TokenError {
pub fn parse_token(discord_user: &User, encrypted_token: &str) -> Result<String, TokenError> {
guard!(let Some(token) = text_decrypt(encrypted_token) else {
Err(TokenError::TokenInvalid)
return Err(TokenError::TokenInvalid)
});
let token_components: Vec<_> = token.splitn(3, ',').collect();
info!(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment