pub fn generate_token(login: LoginInfoDTO) -> String {
    let now = Utc::now().timestamp_nanos() / 1_000_000_000; // nanosecond -> second
    let payload = UserToken {
        iat: now,
        exp: now + ONE_WEEK,
        id: login.id,
        username: login.username,
    };

    jsonwebtoken::encode(&Header::default(), &payload, &EncodingKey::from_secret(include_bytes!("secret.key"))).unwrap()
}
/// Encodes a token for the given login information as a string.
Encodes a token for the given login information as a string.
Encodes a token for the given login information as a string .
pub fn generate_token(login: LoginInfoDTO) -> String {
    let now = Utc::now().timestamp_nanos() / 1_000_000_000; // nanosecond -> second
    let payload = UserToken {
        iat: now,
        exp: now + ONE_WEEK,
        id: login.id,
        username: login.username,
    };
    jsonwebtoken::encode(&Header::default(), &payload, &EncodingKey::from_secret(include_bytes!("secret.key"))).unwrap()
}
pub fn generate_token ( login : LoginInfoDTO ) -> String { let now = Utc :: now ( ) . timestamp_nanos ( ) / 1_000_000_000 ; // nanosecond -> second let payload = UserToken { iat : now , exp : now + ONE_WEEK , id : login . id , username : login . username , } ; jsonwebtoken :: encode ( & Header :: default ( ) , & payload , & EncodingKey :: from_secret ( include_bytes ! ( " " ) ) ) . unwrap ( ) }
Encodes a token for the given login information as a string.
Encodes a token for the given login information as a string .
login
LoginInfoDTO
login
LoginInfoDTO