async fn valid_refresh_token_from_str(user_agent: &str, refresh_token: &str) -> Result<RefreshToken, Error> {
    let refresh_token = RefreshToken::from_str(refresh_token)?;

    // make sure the token is known
    if !STORAGE.refresh_token_exists(&refresh_token).await {
        return Err(Error::RefreshTokenError);
    }

    // remove token if expired
    if refresh_token.exp < chrono::Utc::now().timestamp() {
        return Err(remove_bad_refresh_token(&refresh_token).await);
    }

    // ensure token is used by same user agent
    if user_agent != refresh_token.user_agent {
        println!(
            "token used by different agent {}, token: {:?}",
            user_agent, &refresh_token
        );
        return Err(remove_bad_refresh_token(&refresh_token).await);
    }

    Ok(refresh_token)
}
/// Returns a valid `RefreshToken` on success and an error otherwise.
Returns a valid `RefreshToken` on success and an error otherwise.
Returns a valid ` RefreshToken ` on success and an error otherwise .
async fn valid_refresh_token_from_str(user_agent: &str, refresh_token: &str) -> Result<RefreshToken, Error> {
    let refresh_token = RefreshToken::from_str(refresh_token)?;
    // make sure the token is known
    if !STORAGE.refresh_token_exists(&refresh_token).await {
        return Err(Error::RefreshTokenError);
    }
    // remove token if expired
    if refresh_token.exp < chrono::Utc::now().timestamp() {
        return Err(remove_bad_refresh_token(&refresh_token).await);
    }
    // ensure token is used by same user agent
    if user_agent != refresh_token.user_agent {
        println!(
            "token used by different agent {}, token: {:?}",
            user_agent, &refresh_token
        );
        return Err(remove_bad_refresh_token(&refresh_token).await);
    }
    Ok(refresh_token)
}
async fn valid_refresh_token_from_str ( user_agent : & str , refresh_token : & str ) -> Result < RefreshToken , Error > { let refresh_token = RefreshToken :: from_str ( refresh_token ) ? ; // make sure the token is known if ! STORAGE . refresh_token_exists ( & refresh_token ) . await { return Err ( Error :: RefreshTokenError ) ; } // remove token if expired if refresh_token . exp < chrono :: Utc :: now ( ) . timestamp ( ) { return Err ( remove_bad_refresh_token ( & refresh_token ) . await ) ; } // ensure token is used by same user agent if user_agent != refresh_token . user_agent { println ! ( " " user_agent refresh_token ) ; return Err ( remove_bad_refresh_token ( & refresh_token ) . await ) ; } Ok ( refresh_token ) }
Returns a valid `RefreshToken` on success and an error otherwise.
Returns a valid ` RefreshToken ` on success and an error otherwise .
user_agent
&str
refresh_token
&str
user_agent
&str
refresh_token
&str