Skip to content

Commit

Permalink
feat: 🐛 fix DB unset
Browse files Browse the repository at this point in the history
  • Loading branch information
Eason0729 committed Dec 7, 2023
1 parent 810426c commit 19cbcbc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions backend/src/controller/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ 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 {
#[error("`{0}`")]
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),
Expand Down
1 change: 1 addition & 0 deletions backend/src/init/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8> {
digest::digest(
Expand Down
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 19cbcbc

Please sign in to comment.