- add: Refresh Session call to actually refresh the cache session.
This commit is contained in:
@@ -2,7 +2,7 @@ use crate::grpc::database_service::MyDatabaseService;
|
||||
use crate::grpc::session_service_server::SessionService;
|
||||
use tonic::{Request, Response, Status};
|
||||
use tracing::debug;
|
||||
use crate::grpc::{GetSessionRequest, GetSessionResponse};
|
||||
use crate::grpc::{GetSessionRequest, GetSessionResponse, RefreshSessionRequest, RefreshSessionResponse};
|
||||
|
||||
#[tonic::async_trait]
|
||||
impl SessionService for MyDatabaseService {
|
||||
@@ -22,4 +22,19 @@ impl SessionService for MyDatabaseService {
|
||||
user_id: session.user_id,
|
||||
}))
|
||||
}
|
||||
|
||||
async fn refresh_session(&self, request: Request<RefreshSessionRequest>) -> Result<Response<RefreshSessionResponse>, Status> {
|
||||
let req = request.into_inner();
|
||||
debug!("get_session: {:?}", req);
|
||||
|
||||
let session = self.db.session_repo.refresh_session(&req.session_id).await
|
||||
.map_err(|_| Status::not_found("Session not found"))?;
|
||||
|
||||
let valid = true;
|
||||
|
||||
debug!("session: {:?}", session);
|
||||
Ok(Response::new(RefreshSessionResponse {
|
||||
valid
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user