use jsonwebtoken::{EncodingKey, Header, Validation}; use migration::token; use serde::{Deserialize, Serialize}; use uuid::Uuid; #[derive(Deserialize, Serialize)] struct Claims { sub: Uuid, name: String, } pub fn create_jwt( user: entity::user::Model, key: &EncodingKey, ) -> Result { let claims = Claims { sub: user.id, name: user.name, }; jsonwebtoken::encode(&Header::default(), &claims, key) } pub fn verify(token: &str) { let validation = Validation::new(jsonwebtoken::Algorithm::HS256); // jsonwebtoken::decode(token, , validation) }