diff --git a/backend/src/controller/token.rs b/backend/src/controller/token.rs index 28235364..937e3b8e 100644 --- a/backend/src/controller/token.rs +++ b/backend/src/controller/token.rs @@ -12,7 +12,7 @@ use tracing::instrument; use crate::{init::db::DB, report_internal}; const CLEAN_DUR: time::Duration = time::Duration::from_secs(60 * 30); -type Rand = [u8; 18]; +type Rand = [u8; 28]; #[derive(Debug, thiserror::Error)] pub enum Error { @@ -20,7 +20,7 @@ pub enum Error { Database(#[from] sea_orm::error::DbErr), #[error("expired")] Expired, - #[error("length of token is not 18")] + #[error("length of token is not 28")] InvalidTokenLength, #[error("`{0}`")] Base64(#[from] base64::DecodeError), diff --git a/backend/src/init/db.rs b/backend/src/init/db.rs index 3426c69e..1b2f6db9 100644 --- a/backend/src/init/db.rs +++ b/backend/src/init/db.rs @@ -21,6 +21,7 @@ pub async fn init(config: &GlobalConfig) { .await .expect("fail connecting to database"); init_user(config, &db).await; + DB.set(db).ok(); } fn hash(config: &GlobalConfig, src: &str) -> Vec { digest::digest( diff --git a/justfile b/justfile index cb811395..3838ed61 100644 --- a/justfile +++ b/justfile @@ -12,7 +12,7 @@ dev-judger: prepare: mkdir -p cert - openssl req -x509 -newkey rsa:4096 -keyout cert/key.pem -out cert/cert.pem -sha256 -days 3650 -nodes -subj "/C=XX/ST=StateName/L=CityName/O=CompanyName/OU=CompanySectionName/CN=CommonNameOrHostname" + openssl req -x509 -newkey rsa:4096 -keyout cert/key.pem -out cert/cert.pem -sha256 -days 3650 -nodes -subj "/C=XX/ST=StateName/L=CityName/O=CompanyName/OU=CompanySectionName/CN=localhost" clean: cd ./frontend && yarn cache clean