Compare commits
2 Commits
194139bc30
...
0a9cc09f7b
Author | SHA1 | Date |
---|---|---|
kozabrada123 | 0a9cc09f7b | |
bitfl0wer | e9b3de2342 |
|
@ -3,7 +3,10 @@
|
||||||
// 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::{encode, EncodingKey, Header};
|
use jsonwebtoken::errors::Error;
|
||||||
|
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 {
|
||||||
|
@ -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);
|
let mut validation = Validation::new(Algorithm::HS256);
|
||||||
validation.sub = Some("quartzauth".to_string());
|
//TODO: What is this?
|
||||||
decode(token, &DecodingKey::from_secret(JWT_SECRET), &validation)
|
//validation.sub = Some("quartzauth".to_string());
|
||||||
}*/
|
decode(
|
||||||
|
token,
|
||||||
|
&DecodingKey::from_secret(jwt_secret.as_bytes()),
|
||||||
|
&validation,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue