diff options
Diffstat (limited to 'crates/auth-service/src/server')
-rw-r--r-- | crates/auth-service/src/server/grpc/auth.rs | 22 | ||||
-rw-r--r-- | crates/auth-service/src/server/routes/authorised.rs | 12 |
2 files changed, 29 insertions, 5 deletions
diff --git a/crates/auth-service/src/server/grpc/auth.rs b/crates/auth-service/src/server/grpc/auth.rs index 87113a5..18e7546 100644 --- a/crates/auth-service/src/server/grpc/auth.rs +++ b/crates/auth-service/src/server/grpc/auth.rs @@ -3,8 +3,8 @@ use std::str::FromStr; use jsonwebtoken::DecodingKey; use sellershut_core::{ auth::{ - RegisterUserRequest, RegisterUserResponse, ValidationRequest, ValidationResponse, - auth_server::Auth, + GetPrivateKeyRequest, GetPrivateKeyResponse, RegisterUserRequest, RegisterUserResponse, + ValidationRequest, ValidationResponse, auth_server::Auth, }, users::CreateUserRequest, }; @@ -136,4 +136,22 @@ impl Auth for AppHandle { auth_id: user.id.to_string(), })) } + + async fn get_private_key( + &self, + request: Request<GetPrivateKeyRequest>, + ) -> Result<Response<GetPrivateKeyResponse>, Status> { + let email = request.into_inner().email; + + let private_key = sqlx::query_scalar!( + "select private_key from auth_user where email = $1 + ", + uuid, + ) + .fetch_one(&self.services.postgres) + .await + .unwrap(); + + Ok(Response::new(GetPrivateKeyResponse { private_key })) + } } diff --git a/crates/auth-service/src/server/routes/authorised.rs b/crates/auth-service/src/server/routes/authorised.rs index 552f6c1..63c5a49 100644 --- a/crates/auth-service/src/server/routes/authorised.rs +++ b/crates/auth-service/src/server/routes/authorised.rs @@ -9,7 +9,9 @@ use axum::{ use axum_extra::{TypedHeader, headers}; use oauth2::{AuthorizationCode, TokenResponse}; use reqwest::{StatusCode, header::SET_COOKIE}; -use sellershut_core::auth::{RegisterUserRequest, auth_server::Auth, register_user_request::AccountDetails}; +use sellershut_core::auth::{ + RegisterUserRequest, auth_server::Auth, register_user_request::AccountDetails, +}; use serde::{Deserialize, Serialize}; use sqlx::types::uuid; use time::OffsetDateTime; @@ -123,10 +125,14 @@ pub async fn login_authorised( account: Some(AccountDetails { provider_id: provider, provider_user_id: data.id, - }) + }), }; - let resp = state.register_user(request.into_request()).await.unwrap().into_inner(); + let resp = state + .register_user(request.into_request()) + .await + .unwrap() + .into_inner(); Uuid::parse_str(&resp.auth_id).unwrap() }; |