pub fn verify(secret: &str, token: &str) -> Result<JWTToken, String> {
        let validation = Validation::new(Algorithm::HS256);
        return match decode::<JWTToken>(
            &token,
            &DecodingKey::from_secret(secret.as_ref()),
            &validation,
        ) {
            Ok(c) => Ok(c.claims),
            Err(err) => match *err.kind() {
                ErrorKind::InvalidToken => return Err(String::from("InvalidToken")), // Example on how to handle a specific error
                ErrorKind::InvalidIssuer => return Err(String::from("InvalidIssuer")), // Example on how to handle a specific error
                _ => return Err(String::from("InvalidToken other errors")),
            },
        };
    }
/// verify token invalid
/// secret: your secret string
verify token invalid
secret: your secret string
verify token invalid secret : your secret string
pub fn verify(secret: &str, token: &str) -> Result<JWTToken, String> {
        let validation = Validation::new(Algorithm::HS256);
        return match decode::<JWTToken>(
            &token,
            &DecodingKey::from_secret(secret.as_ref()),
            &validation,
        ) {
            Ok(c) => Ok(c.claims),
            Err(err) => match *err.kind() {
                ErrorKind::InvalidToken => return Err(String::from("InvalidToken")), // Example on how to handle a specific error
                ErrorKind::InvalidIssuer => return Err(String::from("InvalidIssuer")), // Example on how to handle a specific error
                _ => return Err(String::from("InvalidToken other errors")),
            },
        };
    }
pub fn verify ( secret : & str , token : & str ) -> Result < JWTToken , String > { let validation = Validation :: new ( Algorithm :: HS256 ) ; return match decode :: < JWTToken > ( & token , & DecodingKey :: from_secret ( secret . as_ref ( ) ) , & validation , ) { Ok ( c ) => Ok ( c . claims ) , Err ( err ) => match * err . kind ( ) { ErrorKind :: InvalidToken => return Err ( String :: from ( " " ) ) , // Example on how to handle a specific error ErrorKind :: InvalidIssuer => return Err ( String :: from ( " " ) ) , // Example on how to handle a specific error _ => return Err ( String :: from ( " " ) ) , } , } ; }
verify token invalid
secret: your secret string
verify token invalid secret : your secret string
secret
&str
token
&str
secret
&str
token
&str