diff --git a/library/src/token.rs b/library/src/token.rs index a4d338d..396419f 100644 --- a/library/src/token.rs +++ b/library/src/token.rs @@ -28,7 +28,7 @@ fn generate(claim: Claim) -> String { let token = jsonwebtoken::encode( &jsonwebtoken::Header::default(), &claim, - &jsonwebtoken::EncodingKey::from_secret(b"secret"), + &jsonwebtoken::EncodingKey::from_secret(config!().jwt.secret.as_bytes()), ); token.unwrap_or_else(|e| { tracing::error!(error =?e, "生成Token失败"); @@ -39,7 +39,7 @@ fn generate(claim: Claim) -> String { pub fn verify_token(token: &str) -> Result { jsonwebtoken::decode::( token, - &jsonwebtoken::DecodingKey::from_secret(b"secret"), + &jsonwebtoken::DecodingKey::from_secret(config!().jwt.secret.as_bytes()), &jsonwebtoken::Validation::default(), ) .map(|data| data.claims)