diff --git a/examples/error_handling.rs b/examples/error_handling.rs index cd8ea83..01c400d 100644 --- a/examples/error_handling.rs +++ b/examples/error_handling.rs @@ -7,7 +7,7 @@ use bevy_key_rotation::{ AuthProvider, KeyRotationPlugin, KeyRotationSettings, Keystore, KeystoreState, StartKeyRotationExt, TokenRotationError, }; -use std::{sync::Arc, time::Duration}; +use std::sync::Arc; pub struct MyAuthProvider; @@ -24,9 +24,9 @@ impl AuthProvider for MyAuthProvider { access_token: "123".to_string(), refresh_token: "456".to_string(), access_expires: bevy_key_rotation::Instant::now() - + Duration::from_secs(20), + + bevy_key_rotation::Duration::from_secs(20), refresh_expires: bevy_key_rotation::Instant::now() - + Duration::from_secs(60), + + bevy_key_rotation::Duration::from_secs(60), }) } async fn refresh( @@ -56,8 +56,10 @@ fn status_check( return; } - if keystore.access_token_valid_for() < Duration::from_secs(5) { - log::error!("The keystore is about to be non-conformant!"); + if keystore.access_token_valid_for() + < bevy_key_rotation::Duration::from_secs(5) + { + log::warn!("The keystore is about to be non-conformant!"); // You could attempt to re-authenticate from scratch: // commands.start_key_rotation(username, password); // Or panic, or safe your system and prepare to exit, etc. diff --git a/examples/simple.rs b/examples/simple.rs index b9c4d2c..f350f20 100644 --- a/examples/simple.rs +++ b/examples/simple.rs @@ -7,7 +7,7 @@ use bevy_key_rotation::{ AuthProvider, KeyRotationPlugin, KeyRotationSettings, Keystore, StartKeyRotationExt, TokenRotationError, }; -use std::{sync::Arc, time::Duration}; +use std::sync::Arc; pub struct MyAuthProvider; @@ -24,9 +24,9 @@ impl AuthProvider for MyAuthProvider { access_token: random_token(), refresh_token: random_token(), access_expires: bevy_key_rotation::Instant::now() - + Duration::from_secs(10), + + bevy_key_rotation::Duration::from_secs(10), refresh_expires: bevy_key_rotation::Instant::now() - + Duration::from_secs(20), + + bevy_key_rotation::Duration::from_secs(20), }) } async fn refresh( @@ -38,7 +38,8 @@ impl AuthProvider for MyAuthProvider { password: keystore.password, access_token: random_token(), refresh_token: keystore.refresh_token, - access_expires: keystore.access_expires + Duration::from_secs(5), + access_expires: keystore.access_expires + + bevy_key_rotation::Duration::from_secs(5), refresh_expires: keystore.refresh_expires, }) }