implementation of login

This commit is contained in:
filipriec
2025-03-31 10:40:34 +02:00
parent 94eea47b76
commit f71498703a
6 changed files with 25 additions and 30 deletions

View File

@@ -1 +0,0 @@
// src/services/adresar.rs

View File

@@ -0,0 +1,24 @@
// src/services/login.rs
use tonic::transport::Channel;
use common::proto::multieko2::auth::{
auth_service_client::AuthServiceClient,
LoginRequest, LoginResponse
};
pub struct AuthClient {
client: AuthServiceClient<Channel>,
}
impl AuthClient {
pub async fn new() -> Result<Self, Box<dyn std::error::Error>> {
let client = AuthServiceClient::connect("http://[::1]:50051").await?;
Ok(Self { client })
}
pub async fn login(&mut self, identifier: String, password: String) -> Result<LoginResponse, Box<dyn std::error::Error>> {
let request = tonic::Request::new(LoginRequest { identifier, password });
let response = self.client.login(request).await?.into_inner();
Ok(response)
}
}

View File

@@ -1,24 +0,0 @@
// src/services/login.rs
use tonic::transport::Channel;
use common::proto::multieko2::auth::{
auth_service_client::AuthServiceClient,
LoginRequest, LoginResponse
};
pub struct AuthClient {
client: AuthServiceClient<Channel>,
}
impl AuthClient {
pub async fn new() -> Result<Self, Box<dyn std::error::Error>> {
let client = AuthServiceClient::connect("http://[::1]:50051").await?;
Ok(Self { client })
}
pub async fn login(&mut self, identifier: String, password: String) -> Result<LoginResponse, Box<dyn std::error::Error>> {
let request = tonic::Request::new(LoginRequest { identifier, password });
let response = self.client.login(request).await?.into_inner();
Ok(response)
}
}

View File

@@ -1,11 +1,9 @@
// services/mod.rs
pub mod grpc_client;
pub mod adresar;
pub mod table;
pub mod profile;
pub mod auth;
pub mod ui_service;
pub use grpc_client::*;
pub use ui_service::*;
pub use auth::*;

View File

@@ -1 +0,0 @@
// src/services/profile.rs

View File

@@ -1 +0,0 @@
// src/services/table.rs