- add: login via token

- update: login request packet uses token login instead of user & pass
This commit is contained in:
2024-12-10 12:04:04 -05:00
parent e5c961d1b4
commit f847ec0896
2 changed files with 24 additions and 7 deletions

View File

@@ -1,5 +1,5 @@
use crate::auth::auth_service_client::AuthServiceClient;
use crate::auth::{LoginRequest, LoginResponse};
use crate::auth::{LoginRequest, LoginResponse, ValidateTokenRequest, ValidateTokenResponse};
use tonic::transport::Channel;
pub struct AuthClient {
@@ -21,4 +21,13 @@ impl AuthClient {
let response = self.client.login(request).await?;
Ok(response.into_inner())
}
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(),
};
let response = self.client.validate_token(request).await?;
Ok(response.into_inner())
}
}