implementation of login
This commit is contained in:
@@ -1 +0,0 @@
|
|||||||
// src/services/adresar.rs
|
|
||||||
@@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +1,9 @@
|
|||||||
// services/mod.rs
|
// services/mod.rs
|
||||||
|
|
||||||
pub mod grpc_client;
|
pub mod grpc_client;
|
||||||
pub mod adresar;
|
|
||||||
pub mod table;
|
|
||||||
pub mod profile;
|
|
||||||
pub mod auth;
|
pub mod auth;
|
||||||
pub mod ui_service;
|
pub mod ui_service;
|
||||||
|
|
||||||
pub use grpc_client::*;
|
pub use grpc_client::*;
|
||||||
pub use ui_service::*;
|
pub use ui_service::*;
|
||||||
|
pub use auth::*;
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
// src/services/profile.rs
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
// src/services/table.rs
|
|
||||||
Reference in New Issue
Block a user