- add: logout grpc function

- add: logout packet handler
- add: connection state and service for storing connection data
- add: session service calls to auth-service
- fix: compile error on database service due to moved redis cache
This commit is contained in:
2024-12-20 14:46:00 -05:00
parent 3c1f8c40d6
commit 18afa71d74
22 changed files with 265 additions and 46 deletions

View File

@@ -1,5 +1,5 @@
use crate::auth::auth_service_client::AuthServiceClient;
use crate::auth::{LoginRequest, LoginResponse, ValidateTokenRequest, ValidateTokenResponse};
use crate::auth::{Empty, LoginRequest, LoginResponse, LogoutRequest, ValidateTokenRequest, ValidateTokenResponse};
use tonic::transport::Channel;
pub struct AuthClient {
@@ -12,10 +12,11 @@ impl AuthClient {
Ok(AuthClient { client })
}
pub async fn login(&mut self, username: &str, password: &str) -> Result<LoginResponse, Box<dyn std::error::Error + Send + Sync>> {
pub async fn login(&mut self, username: &str, password: &str, ip_address: &str) -> Result<LoginResponse, Box<dyn std::error::Error + Send + Sync>> {
let request = LoginRequest {
username: username.to_string(),
password: password.to_string(),
ip_address: ip_address.to_string(),
};
let response = self.client.login(request).await?;
@@ -24,10 +25,19 @@ impl AuthClient {
pub async fn login_token(&mut self, token: &str) -> Result<ValidateTokenResponse, Box<dyn std::error::Error + Send + Sync>> {
let request = ValidateTokenRequest {
token: token.to_string(),
token: token.to_string()
};
let response = self.client.validate_token(request).await?;
Ok(response.into_inner())
}
pub async fn logout(&mut self, session_id: &str) -> Result<Empty, Box<dyn std::error::Error + Send + Sync>> {
let request = LogoutRequest {
session_id: session_id.to_string(),
};
let response = self.client.logout(request).await?;
Ok(response.into_inner())
}
}