From 3f23a66f6290eb22c106ed392ef1f1900172552c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E8=BF=90=E5=AE=B6?= Date: Wed, 22 May 2024 18:03:45 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=9F=E6=88=90token=E4=BD=BF=E7=94=A8secret?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/src/token.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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)