- add: ability to refresh the current session

- add: delete type to delete character request
- add: ability to update key in redis
- add: handle alive packet to refresh the session
- fix: delete now actually returns the time remaining correctly
- fix: character list now has the correct time until character deletion
This commit is contained in:
2025-01-08 02:03:27 -05:00
parent 584892ab97
commit 6d35d15ac3
16 changed files with 158 additions and 25 deletions

View File

@@ -9,7 +9,7 @@ use crate::users::{hash_password, verify_user};
use chrono::{Duration, Utc};
use rand::Rng;
use tonic::{Request, Response, Status};
use tracing::{error, info, warn};
use tracing::{debug, error, info, warn};
pub struct MyAuthService {
pub db_client: Arc<DatabaseClient>,
@@ -105,11 +105,35 @@ impl AuthService for MyAuthService {
match response {
Ok(res) => {
println!("Session valid: {:?}", res.into_inner());
debug!("Session valid: {:?}", res.into_inner());
Ok(Response::new(ValidateSessionResponse { valid: true }))
}
Err(_) => {
println!("Session invalid or not found");
debug!("Session invalid or not found");
Ok(Response::new(ValidateSessionResponse { valid: false }))
}
}
}
async fn refresh_session(
&self,
request: Request<ValidateSessionRequest>,
) -> Result<Response<ValidateSessionResponse>, Status> {
let req = request.into_inner();
let response = self
.session_client.as_ref().clone()
.refresh_session(GetSessionRequest {
session_id: req.session_id,
})
.await;
match response {
Ok(res) => {
debug!("Session valid: {:?}", res.into_inner());
Ok(Response::new(ValidateSessionResponse { valid: true }))
}
Err(_) => {
debug!("Session invalid or not found");
Ok(Response::new(ValidateSessionResponse { valid: false }))
}
}