1 use crate::settings::structs::Settings;
2 use jsonwebtoken::{decode, encode, DecodingKey, EncodingKey, Header, TokenData, Validation};
3 use serde::{Deserialize, Serialize};
7 #[derive(Debug, Serialize, Deserialize)]
9 pub local_user_id: i32,
14 pub fn decode(jwt: &str) -> Result<TokenData<Claims>, jsonwebtoken::errors::Error> {
17 ..Validation::default()
21 &DecodingKey::from_secret(Settings::get().jwt_secret().as_ref()),
26 pub fn jwt(local_user_id: i32, hostname: String) -> Result<Jwt, jsonwebtoken::errors::Error> {
27 let my_claims = Claims {
34 &EncodingKey::from_secret(Settings::get().jwt_secret().as_ref()),