Compare commits

..

1 Commits

Author SHA1 Message Date
kozabrada123 194139bc30
Merge cfccae8060 into cb3551dcd4 2024-08-22 00:33:53 +02:00
1 changed files with 5 additions and 13 deletions

View File

@ -3,10 +3,7 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
use crate::types::utils::Snowflake; use crate::types::utils::Snowflake;
use jsonwebtoken::errors::Error; use jsonwebtoken::{encode, EncodingKey, Header};
use jsonwebtoken::{
decode, encode, Algorithm, DecodingKey, EncodingKey, Header, TokenData, Validation,
};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
pub fn generate_token(id: &Snowflake, email: String, jwt_key: &str) -> String { pub fn generate_token(id: &Snowflake, email: String, jwt_key: &str) -> String {
@ -45,13 +42,8 @@ pub fn build_token(claims: &Claims, jwt_key: &str) -> Result<String, jsonwebtoke
) )
} }
pub fn decode_token(token: &str, jwt_secret: &str) -> Result<TokenData<Claims>, Error> { /*pub fn decode_token(token: &str) -> Result<TokenData<Claims>, Error> {
let mut validation = Validation::new(Algorithm::HS256); let mut validation = Validation::new(Algorithm::HS256);
//TODO: What is this? validation.sub = Some("quartzauth".to_string());
//validation.sub = Some("quartzauth".to_string()); decode(token, &DecodingKey::from_secret(JWT_SECRET), &validation)
decode( }*/
token,
&DecodingKey::from_secret(jwt_secret.as_bytes()),
&validation,
)
}