Compare commits

...

2 Commits

Author SHA1 Message Date
kozabrada123 0a9cc09f7b
Merge e9b3de2342 into cb3551dcd4 2024-08-22 19:52:35 +00:00
bitfl0wer e9b3de2342
Uncomment and update decode_token() 2024-08-22 21:52:29 +02:00
1 changed files with 13 additions and 5 deletions

View File

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