From df00a14064d3210390db7d8f7c4a6b76948c88b0 Mon Sep 17 00:00:00 2001 From: tusharshah21 Date: Fri, 10 Oct 2025 08:11:56 +0000 Subject: [PATCH 1/3] feat: Implement SIWE nonce-based authentication --- ...f0bff9dcf5f133ecb58bf2706104e55d3490.json} | 12 +++-- ...9e28f8b95cedbd9da3b5a7f2b5ced0505462.json} | 12 +++-- ...640e73d70dde72e7412ca265b30db5ac4249.json} | 12 +++-- ...8ed4aab6d7f3a5f5d88ae151cb6c21666761d.json | 22 ++++++++ ...d020c23a6650ec0bac46c56c30bc3d9c8142.json} | 5 +- ...96ded14179f08a15e3235d3e95b95964bd2c7.json | 14 +++++ backend/migrations/003_add_nonces.sql | 3 ++ .../application/commands/get_login_nonce.rs | 19 +++++++ backend/src/application/commands/mod.rs | 1 + backend/src/application/dtos/auth_dtos.rs | 10 ++++ backend/src/domain/entities/profile.rs | 2 + .../domain/repositories/profile_repository.rs | 8 +++ backend/src/domain/services/auth_service.rs | 2 +- .../postgres_profile_repository.rs | 52 +++++++++++++++++-- .../ethereum_address_verification_service.rs | 31 ++++++----- backend/src/presentation/api.rs | 12 +++-- backend/src/presentation/handlers.rs | 19 ++++++- backend/src/presentation/middlewares.rs | 19 +++++-- backend/tests/integration_github_handle.rs | 27 +++++----- backend/tests/profile_tests.rs | 18 +++++++ 20 files changed, 248 insertions(+), 52 deletions(-) rename backend/.sqlx/{query-fd6f338fcae9c81fbf1d7590574fa950a74fa68daabb48c80a0a7754e4066987.json => query-21d41f830b745d6af6e1319ee36ef0bff9dcf5f133ecb58bf2706104e55d3490.json} (74%) rename backend/.sqlx/{query-b521c6c7f362753693d7059c6815de444a5c6aadc1a9950d9d71f49f52dee768.json => query-5b21241db59e84080d36c67abb309e28f8b95cedbd9da3b5a7f2b5ced0505462.json} (77%) rename backend/.sqlx/{query-177358fec702a5f78c1ff0dbd5eed42fa868487c84ebef42dfcf695e9ce42725.json => query-d23893061ef0e487ff20489fc5f4640e73d70dde72e7412ca265b30db5ac4249.json} (75%) create mode 100644 backend/.sqlx/query-d79097da6ad7c82305d728beb248ed4aab6d7f3a5f5d88ae151cb6c21666761d.json rename backend/.sqlx/{query-7acd8c9bc567ef80f66a38130bb708068882a4559856e38e6231405e9acc5a74.json => query-e4c05cdcfce8dddaf75c30de7e20d020c23a6650ec0bac46c56c30bc3d9c8142.json} (58%) create mode 100644 backend/.sqlx/query-fe47a9ce9d61692552d87b31b3596ded14179f08a15e3235d3e95b95964bd2c7.json create mode 100644 backend/migrations/003_add_nonces.sql create mode 100644 backend/src/application/commands/get_login_nonce.rs diff --git a/backend/.sqlx/query-fd6f338fcae9c81fbf1d7590574fa950a74fa68daabb48c80a0a7754e4066987.json b/backend/.sqlx/query-21d41f830b745d6af6e1319ee36ef0bff9dcf5f133ecb58bf2706104e55d3490.json similarity index 74% rename from backend/.sqlx/query-fd6f338fcae9c81fbf1d7590574fa950a74fa68daabb48c80a0a7754e4066987.json rename to backend/.sqlx/query-21d41f830b745d6af6e1319ee36ef0bff9dcf5f133ecb58bf2706104e55d3490.json index 7e5ec3a..bb66029 100644 --- a/backend/.sqlx/query-fd6f338fcae9c81fbf1d7590574fa950a74fa68daabb48c80a0a7754e4066987.json +++ b/backend/.sqlx/query-21d41f830b745d6af6e1319ee36ef0bff9dcf5f133ecb58bf2706104e55d3490.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT address, name, description, avatar_url, github_login, created_at, updated_at\n FROM profiles\n WHERE address = $1\n ", + "query": "\n SELECT address, name, description, avatar_url, github_login, login_nonce, created_at, updated_at\n FROM profiles\n WHERE LOWER(github_login) = LOWER($1)\n ", "describe": { "columns": [ { @@ -30,11 +30,16 @@ }, { "ordinal": 5, + "name": "login_nonce", + "type_info": "Int8" + }, + { + "ordinal": 6, "name": "created_at", "type_info": "Timestamptz" }, { - "ordinal": 6, + "ordinal": 7, "name": "updated_at", "type_info": "Timestamptz" } @@ -50,9 +55,10 @@ true, true, true, + false, true, true ] }, - "hash": "fd6f338fcae9c81fbf1d7590574fa950a74fa68daabb48c80a0a7754e4066987" + "hash": "21d41f830b745d6af6e1319ee36ef0bff9dcf5f133ecb58bf2706104e55d3490" } diff --git a/backend/.sqlx/query-b521c6c7f362753693d7059c6815de444a5c6aadc1a9950d9d71f49f52dee768.json b/backend/.sqlx/query-5b21241db59e84080d36c67abb309e28f8b95cedbd9da3b5a7f2b5ced0505462.json similarity index 77% rename from backend/.sqlx/query-b521c6c7f362753693d7059c6815de444a5c6aadc1a9950d9d71f49f52dee768.json rename to backend/.sqlx/query-5b21241db59e84080d36c67abb309e28f8b95cedbd9da3b5a7f2b5ced0505462.json index 0e00234..076074a 100644 --- a/backend/.sqlx/query-b521c6c7f362753693d7059c6815de444a5c6aadc1a9950d9d71f49f52dee768.json +++ b/backend/.sqlx/query-5b21241db59e84080d36c67abb309e28f8b95cedbd9da3b5a7f2b5ced0505462.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT address, name, description, avatar_url, github_login, created_at, updated_at\n FROM profiles\n ", + "query": "\n SELECT address, name, description, avatar_url, github_login, login_nonce, created_at, updated_at\n FROM profiles\n ", "describe": { "columns": [ { @@ -30,11 +30,16 @@ }, { "ordinal": 5, + "name": "login_nonce", + "type_info": "Int8" + }, + { + "ordinal": 6, "name": "created_at", "type_info": "Timestamptz" }, { - "ordinal": 6, + "ordinal": 7, "name": "updated_at", "type_info": "Timestamptz" } @@ -48,9 +53,10 @@ true, true, true, + false, true, true ] }, - "hash": "b521c6c7f362753693d7059c6815de444a5c6aadc1a9950d9d71f49f52dee768" + "hash": "5b21241db59e84080d36c67abb309e28f8b95cedbd9da3b5a7f2b5ced0505462" } diff --git a/backend/.sqlx/query-177358fec702a5f78c1ff0dbd5eed42fa868487c84ebef42dfcf695e9ce42725.json b/backend/.sqlx/query-d23893061ef0e487ff20489fc5f4640e73d70dde72e7412ca265b30db5ac4249.json similarity index 75% rename from backend/.sqlx/query-177358fec702a5f78c1ff0dbd5eed42fa868487c84ebef42dfcf695e9ce42725.json rename to backend/.sqlx/query-d23893061ef0e487ff20489fc5f4640e73d70dde72e7412ca265b30db5ac4249.json index 020138d..3329f2f 100644 --- a/backend/.sqlx/query-177358fec702a5f78c1ff0dbd5eed42fa868487c84ebef42dfcf695e9ce42725.json +++ b/backend/.sqlx/query-d23893061ef0e487ff20489fc5f4640e73d70dde72e7412ca265b30db5ac4249.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT address, name, description, avatar_url, github_login, created_at, updated_at\n FROM profiles\n WHERE LOWER(github_login) = LOWER($1)\n ", + "query": "\n SELECT address, name, description, avatar_url, github_login, login_nonce, created_at, updated_at\n FROM profiles\n WHERE address = $1\n ", "describe": { "columns": [ { @@ -30,11 +30,16 @@ }, { "ordinal": 5, + "name": "login_nonce", + "type_info": "Int8" + }, + { + "ordinal": 6, "name": "created_at", "type_info": "Timestamptz" }, { - "ordinal": 6, + "ordinal": 7, "name": "updated_at", "type_info": "Timestamptz" } @@ -50,9 +55,10 @@ true, true, true, + false, true, true ] }, - "hash": "177358fec702a5f78c1ff0dbd5eed42fa868487c84ebef42dfcf695e9ce42725" + "hash": "d23893061ef0e487ff20489fc5f4640e73d70dde72e7412ca265b30db5ac4249" } diff --git a/backend/.sqlx/query-d79097da6ad7c82305d728beb248ed4aab6d7f3a5f5d88ae151cb6c21666761d.json b/backend/.sqlx/query-d79097da6ad7c82305d728beb248ed4aab6d7f3a5f5d88ae151cb6c21666761d.json new file mode 100644 index 0000000..08b1944 --- /dev/null +++ b/backend/.sqlx/query-d79097da6ad7c82305d728beb248ed4aab6d7f3a5f5d88ae151cb6c21666761d.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT login_nonce\n FROM profiles\n WHERE address = $1\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "login_nonce", + "type_info": "Int8" + } + ], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [ + false + ] + }, + "hash": "d79097da6ad7c82305d728beb248ed4aab6d7f3a5f5d88ae151cb6c21666761d" +} diff --git a/backend/.sqlx/query-7acd8c9bc567ef80f66a38130bb708068882a4559856e38e6231405e9acc5a74.json b/backend/.sqlx/query-e4c05cdcfce8dddaf75c30de7e20d020c23a6650ec0bac46c56c30bc3d9c8142.json similarity index 58% rename from backend/.sqlx/query-7acd8c9bc567ef80f66a38130bb708068882a4559856e38e6231405e9acc5a74.json rename to backend/.sqlx/query-e4c05cdcfce8dddaf75c30de7e20d020c23a6650ec0bac46c56c30bc3d9c8142.json index 634fb2e..86f6186 100644 --- a/backend/.sqlx/query-7acd8c9bc567ef80f66a38130bb708068882a4559856e38e6231405e9acc5a74.json +++ b/backend/.sqlx/query-e4c05cdcfce8dddaf75c30de7e20d020c23a6650ec0bac46c56c30bc3d9c8142.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n INSERT INTO profiles (address, name, description, avatar_url, github_login, created_at, updated_at)\n VALUES ($1, $2, $3, $4, $5, $6, $7)\n ", + "query": "\n INSERT INTO profiles (address, name, description, avatar_url, github_login, login_nonce, created_at, updated_at)\n VALUES ($1, $2, $3, $4, $5, $6, $7, $8)\n ", "describe": { "columns": [], "parameters": { @@ -10,11 +10,12 @@ "Text", "Text", "Text", + "Int8", "Timestamptz", "Timestamptz" ] }, "nullable": [] }, - "hash": "7acd8c9bc567ef80f66a38130bb708068882a4559856e38e6231405e9acc5a74" + "hash": "e4c05cdcfce8dddaf75c30de7e20d020c23a6650ec0bac46c56c30bc3d9c8142" } diff --git a/backend/.sqlx/query-fe47a9ce9d61692552d87b31b3596ded14179f08a15e3235d3e95b95964bd2c7.json b/backend/.sqlx/query-fe47a9ce9d61692552d87b31b3596ded14179f08a15e3235d3e95b95964bd2c7.json new file mode 100644 index 0000000..afb34ed --- /dev/null +++ b/backend/.sqlx/query-fe47a9ce9d61692552d87b31b3596ded14179f08a15e3235d3e95b95964bd2c7.json @@ -0,0 +1,14 @@ +{ + "db_name": "PostgreSQL", + "query": "\n UPDATE profiles\n SET login_nonce = login_nonce + 1\n WHERE address = $1\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Text" + ] + }, + "nullable": [] + }, + "hash": "fe47a9ce9d61692552d87b31b3596ded14179f08a15e3235d3e95b95964bd2c7" +} diff --git a/backend/migrations/003_add_nonces.sql b/backend/migrations/003_add_nonces.sql new file mode 100644 index 0000000..a8e4b55 --- /dev/null +++ b/backend/migrations/003_add_nonces.sql @@ -0,0 +1,3 @@ +-- Add login_nonce column to profiles table +-- The nonce starts at 1 and increments with each successful login +ALTER TABLE profiles ADD COLUMN IF NOT EXISTS login_nonce BIGINT NOT NULL DEFAULT 1; diff --git a/backend/src/application/commands/get_login_nonce.rs b/backend/src/application/commands/get_login_nonce.rs new file mode 100644 index 0000000..5e33796 --- /dev/null +++ b/backend/src/application/commands/get_login_nonce.rs @@ -0,0 +1,19 @@ +use std::sync::Arc; + +use crate::domain::{repositories::ProfileRepository, value_objects::WalletAddress}; + +pub async fn get_login_nonce( + profile_repository: Arc, + address: String, +) -> Result { + let wallet_address = WalletAddress(address); + + match profile_repository + .get_login_nonce_by_wallet_address(&wallet_address) + .await + { + Ok(Some(nonce)) => Ok(nonce), + Ok(None) => Err("Profile not found".to_string()), + Err(e) => Err(format!("Error fetching nonce: {}", e)), + } +} diff --git a/backend/src/application/commands/mod.rs b/backend/src/application/commands/mod.rs index ac3cc0c..29342de 100644 --- a/backend/src/application/commands/mod.rs +++ b/backend/src/application/commands/mod.rs @@ -1,4 +1,5 @@ pub mod create_profile; pub mod get_all_profiles; +pub mod get_login_nonce; pub mod get_profile; pub mod update_profile; diff --git a/backend/src/application/dtos/auth_dtos.rs b/backend/src/application/dtos/auth_dtos.rs index 8b38ce4..c94f36c 100644 --- a/backend/src/application/dtos/auth_dtos.rs +++ b/backend/src/application/dtos/auth_dtos.rs @@ -1,10 +1,20 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Serialize, Deserialize)] pub struct VerifyMessageRequest { pub address: String, pub nonce: String, pub message: String, } +#[derive(Debug, Serialize, Deserialize)] pub struct VerifyMessageResponse { pub success: bool, pub address: String, } + +#[derive(Debug, Serialize, Deserialize)] +pub struct NonceResponse { + pub nonce: i64, + pub address: String, +} diff --git a/backend/src/domain/entities/profile.rs b/backend/src/domain/entities/profile.rs index c13301d..fd42982 100644 --- a/backend/src/domain/entities/profile.rs +++ b/backend/src/domain/entities/profile.rs @@ -10,6 +10,7 @@ pub struct Profile { pub description: Option, pub avatar_url: Option, pub github_login: Option, + pub login_nonce: i64, pub created_at: DateTime, pub updated_at: DateTime, } @@ -23,6 +24,7 @@ impl Profile { description: None, avatar_url: None, github_login: None, + login_nonce: 1, created_at: now, updated_at: now, } diff --git a/backend/src/domain/repositories/profile_repository.rs b/backend/src/domain/repositories/profile_repository.rs index 61b6245..3658458 100644 --- a/backend/src/domain/repositories/profile_repository.rs +++ b/backend/src/domain/repositories/profile_repository.rs @@ -16,4 +16,12 @@ pub trait ProfileRepository: Send + Sync { &self, github_login: &str, ) -> Result, Box>; + async fn get_login_nonce_by_wallet_address( + &self, + address: &WalletAddress, + ) -> Result, Box>; + async fn increment_login_nonce( + &self, + address: &WalletAddress, + ) -> Result<(), Box>; } diff --git a/backend/src/domain/services/auth_service.rs b/backend/src/domain/services/auth_service.rs index 3afaf9f..2ca750c 100644 --- a/backend/src/domain/services/auth_service.rs +++ b/backend/src/domain/services/auth_service.rs @@ -4,7 +4,7 @@ use crate::domain::value_objects::wallet_address::WalletAddress; #[derive(Debug, Clone, PartialEq, Eq)] pub struct AuthChallenge { - pub nonce: String, + pub nonce: i64, pub address: String, } diff --git a/backend/src/infrastructure/repositories/postgres_profile_repository.rs b/backend/src/infrastructure/repositories/postgres_profile_repository.rs index b480585..e951f8e 100644 --- a/backend/src/infrastructure/repositories/postgres_profile_repository.rs +++ b/backend/src/infrastructure/repositories/postgres_profile_repository.rs @@ -24,7 +24,7 @@ impl ProfileRepository for PostgresProfileRepository { ) -> Result, Box> { let row = sqlx::query!( r#" - SELECT address, name, description, avatar_url, github_login, created_at, updated_at + SELECT address, name, description, avatar_url, github_login, login_nonce, created_at, updated_at FROM profiles WHERE address = $1 "#, @@ -40,6 +40,7 @@ impl ProfileRepository for PostgresProfileRepository { description: r.description, avatar_url: r.avatar_url, github_login: r.github_login, + login_nonce: r.login_nonce, created_at: r.created_at.unwrap(), updated_at: r.updated_at.unwrap(), })) @@ -48,7 +49,7 @@ impl ProfileRepository for PostgresProfileRepository { async fn find_all(&self) -> Result, Box> { let rows = sqlx::query!( r#" - SELECT address, name, description, avatar_url, github_login, created_at, updated_at + SELECT address, name, description, avatar_url, github_login, login_nonce, created_at, updated_at FROM profiles "#, ) @@ -64,6 +65,7 @@ impl ProfileRepository for PostgresProfileRepository { description: r.description, avatar_url: r.avatar_url, github_login: r.github_login, + login_nonce: r.login_nonce, created_at: r.created_at.unwrap(), updated_at: r.updated_at.unwrap(), }) @@ -73,14 +75,15 @@ impl ProfileRepository for PostgresProfileRepository { async fn create(&self, profile: &Profile) -> Result<(), Box> { sqlx::query!( r#" - INSERT INTO profiles (address, name, description, avatar_url, github_login, created_at, updated_at) - VALUES ($1, $2, $3, $4, $5, $6, $7) + INSERT INTO profiles (address, name, description, avatar_url, github_login, login_nonce, created_at, updated_at) + VALUES ($1, $2, $3, $4, $5, $6, $7, $8) "#, profile.address.as_str(), profile.name, profile.description, profile.avatar_url, profile.github_login, + profile.login_nonce, profile.created_at, profile.updated_at ) @@ -133,7 +136,7 @@ impl ProfileRepository for PostgresProfileRepository { ) -> Result, Box> { let row = sqlx::query!( r#" - SELECT address, name, description, avatar_url, github_login, created_at, updated_at + SELECT address, name, description, avatar_url, github_login, login_nonce, created_at, updated_at FROM profiles WHERE LOWER(github_login) = LOWER($1) "#, @@ -149,8 +152,47 @@ impl ProfileRepository for PostgresProfileRepository { description: r.description, avatar_url: r.avatar_url, github_login: r.github_login, + login_nonce: r.login_nonce, created_at: r.created_at.unwrap(), updated_at: r.updated_at.unwrap(), })) } + + async fn get_login_nonce_by_wallet_address( + &self, + address: &WalletAddress, + ) -> Result, Box> { + let row = sqlx::query!( + r#" + SELECT login_nonce + FROM profiles + WHERE address = $1 + "#, + address.as_str() + ) + .fetch_optional(&self.pool) + .await + .map_err(|e| Box::new(e) as Box)?; + + Ok(row.map(|r| r.login_nonce)) + } + + async fn increment_login_nonce( + &self, + address: &WalletAddress, + ) -> Result<(), Box> { + sqlx::query!( + r#" + UPDATE profiles + SET login_nonce = login_nonce + 1 + WHERE address = $1 + "#, + address.as_str() + ) + .execute(&self.pool) + .await + .map_err(|e| Box::new(e) as Box)?; + + Ok(()) + } } diff --git a/backend/src/infrastructure/services/ethereum_address_verification_service.rs b/backend/src/infrastructure/services/ethereum_address_verification_service.rs index e8ff93f..35d740c 100644 --- a/backend/src/infrastructure/services/ethereum_address_verification_service.rs +++ b/backend/src/infrastructure/services/ethereum_address_verification_service.rs @@ -2,21 +2,21 @@ use async_trait::async_trait; use ethers::core::utils::hash_message; use ethers::types::{Address, Signature}; use std::str::FromStr; +use std::sync::Arc; +use crate::domain::repositories::ProfileRepository; use crate::domain::services::auth_service::{AuthChallenge, AuthResult, AuthService}; use crate::domain::value_objects::WalletAddress; -pub struct EthereumAddressVerificationService {} - -impl EthereumAddressVerificationService { - pub fn new() -> Self { - Self {} - } +pub struct EthereumAddressVerificationService { + profile_repository: Arc, } -impl Default for EthereumAddressVerificationService { - fn default() -> Self { - Self::new() +impl EthereumAddressVerificationService { + pub fn new(profile_repository: Arc) -> Self { + Self { + profile_repository, + } } } @@ -27,10 +27,11 @@ impl AuthService for EthereumAddressVerificationService { challenge: &AuthChallenge, signature: &str, ) -> Result, Box> { - const EXPECTED_MSG: &str = "LOGIN_NONCE"; // or whatever constant string you are signing + // Create the message with the nonce + let message = format!("Sign this message to authenticate with The Guild.\n\nNonce: {}", challenge.nonce); // EIP-191 prefix + keccak256 - let msg_hash = hash_message(EXPECTED_MSG); + let msg_hash = hash_message(message); // Parse signature and expected address let sig = Signature::from_str(signature)?; @@ -40,8 +41,14 @@ impl AuthService for EthereumAddressVerificationService { let recovered = sig.recover(msg_hash)?; if recovered == expected { + // Increment the nonce after successful verification + let wallet_address = WalletAddress(challenge.address.clone()); + self.profile_repository + .increment_login_nonce(&wallet_address) + .await?; + Ok(Some(AuthResult { - wallet_address: WalletAddress(challenge.address.clone()), + wallet_address, })) } else { Ok(None) diff --git a/backend/src/presentation/api.rs b/backend/src/presentation/api.rs index 09fc099..b712dfd 100644 --- a/backend/src/presentation/api.rs +++ b/backend/src/presentation/api.rs @@ -20,18 +20,18 @@ use tower_http::{ }; use super::handlers::{ - create_profile_handler, delete_profile_handler, get_all_profiles_handler, get_profile_handler, - update_profile_handler, + create_profile_handler, delete_profile_handler, get_all_profiles_handler, get_nonce_handler, + get_profile_handler, update_profile_handler, }; use super::middlewares::{eth_auth_layer, test_auth_layer}; pub async fn create_app(pool: sqlx::PgPool) -> Router { - let auth_service = EthereumAddressVerificationService::new(); - let profile_repository = PostgresProfileRepository::new(pool); + let profile_repository = Arc::from(PostgresProfileRepository::new(pool)); + let auth_service = EthereumAddressVerificationService::new(profile_repository.clone()); let state: AppState = AppState { - profile_repository: Arc::from(profile_repository), + profile_repository, auth_service: Arc::from(auth_service), }; @@ -50,6 +50,7 @@ pub async fn create_app(pool: sqlx::PgPool) -> Router { let public_routes = Router::new() .route("/profiles/:address", get(get_profile_handler)) .route("/profiles", get(get_all_profiles_handler)) + .route("/auth/nonce/:address", get(get_nonce_handler)) .with_state(state.clone()); Router::new() @@ -86,6 +87,7 @@ pub fn test_api(state: AppState) -> Router { let public_routes = Router::new() .route("/profiles/:address", get(get_profile_handler)) .route("/profiles", get(get_all_profiles_handler)) + .route("/auth/nonce/:address", get(get_nonce_handler)) .with_state(state.clone()); Router::new() diff --git a/backend/src/presentation/handlers.rs b/backend/src/presentation/handlers.rs index ffc1387..c02fd9b 100644 --- a/backend/src/presentation/handlers.rs +++ b/backend/src/presentation/handlers.rs @@ -9,9 +9,10 @@ use crate::{ application::{ commands::{ create_profile::create_profile, get_all_profiles::get_all_profiles, - get_profile::get_profile, update_profile::update_profile, + get_login_nonce::get_login_nonce, get_profile::get_profile, + update_profile::update_profile, }, - dtos::{CreateProfileRequest, ProfileResponse, UpdateProfileRequest}, + dtos::{CreateProfileRequest, NonceResponse, ProfileResponse, UpdateProfileRequest}, }, domain::value_objects::WalletAddress, }; @@ -76,3 +77,17 @@ pub async fn delete_profile_handler( .unwrap(); StatusCode::ACCEPTED } + +pub async fn get_nonce_handler( + State(state): State, + Path(address): Path, +) -> impl IntoResponse { + match get_login_nonce(state.profile_repository, address.clone()).await { + Ok(nonce) => Json(NonceResponse { + nonce, + address, + }) + .into_response(), + Err(e) => (StatusCode::NOT_FOUND, Json(serde_json::json!({"error": e}))).into_response(), + } +} diff --git a/backend/src/presentation/middlewares.rs b/backend/src/presentation/middlewares.rs index 903dd32..ab07ee9 100644 --- a/backend/src/presentation/middlewares.rs +++ b/backend/src/presentation/middlewares.rs @@ -43,20 +43,31 @@ pub async fn eth_auth_layer( .map(str::to_owned) .ok_or(StatusCode::UNAUTHORIZED)?; - let nonce = "NONCE"; + // Get the current nonce from the database + let wallet_address = crate::domain::value_objects::WalletAddress(address.clone()); + let nonce = state + .profile_repository + .get_login_nonce_by_wallet_address(&wallet_address) + .await + .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)? + .ok_or(StatusCode::UNAUTHORIZED)?; // Profile must exist - state + let result = state .auth_service .verify_signature( &AuthChallenge { address: address.clone().to_string(), - nonce: nonce.to_string(), + nonce, }, &signature, - ) // define the signature you like + ) .await .map_err(|_| StatusCode::UNAUTHORIZED)?; + if result.is_none() { + return Err(StatusCode::UNAUTHORIZED); + } + // Inject identity for handlers: req.extensions_mut() .insert(VerifiedWallet(address.to_string())); diff --git a/backend/tests/integration_github_handle.rs b/backend/tests/integration_github_handle.rs index bd41e0b..4c00b44 100644 --- a/backend/tests/integration_github_handle.rs +++ b/backend/tests/integration_github_handle.rs @@ -13,11 +13,12 @@ async fn valid_github_handle_works() { let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); let addr = listener.local_addr().unwrap(); let pool = sqlx::PgPool::connect(&database_url).await.unwrap(); - let profile_repository = - guild_backend::infrastructure::repositories::PostgresProfileRepository::new(pool.clone()); - let auth_service = guild_backend::infrastructure::services::ethereum_address_verification_service::EthereumAddressVerificationService::new(); + let profile_repository = std::sync::Arc::new( + guild_backend::infrastructure::repositories::PostgresProfileRepository::new(pool.clone()) + ); + let auth_service = guild_backend::infrastructure::services::ethereum_address_verification_service::EthereumAddressVerificationService::new(profile_repository.clone()); let state = AppState { - profile_repository: std::sync::Arc::new(profile_repository), + profile_repository, auth_service: std::sync::Arc::new(auth_service), }; let app = test_api(state); @@ -80,11 +81,12 @@ async fn invalid_format_rejected() { let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); let addr = listener.local_addr().unwrap(); let pool = sqlx::PgPool::connect(&database_url).await.unwrap(); - let profile_repository = - guild_backend::infrastructure::repositories::PostgresProfileRepository::new(pool.clone()); - let auth_service = guild_backend::infrastructure::services::ethereum_address_verification_service::EthereumAddressVerificationService::new(); + let profile_repository = std::sync::Arc::new( + guild_backend::infrastructure::repositories::PostgresProfileRepository::new(pool.clone()) + ); + let auth_service = guild_backend::infrastructure::services::ethereum_address_verification_service::EthereumAddressVerificationService::new(profile_repository.clone()); let state = AppState { - profile_repository: std::sync::Arc::new(profile_repository), + profile_repository, auth_service: std::sync::Arc::new(auth_service), }; let app = test_api(state); @@ -154,11 +156,12 @@ async fn conflict_case_insensitive() { let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); let addr = listener.local_addr().unwrap(); let pool = sqlx::PgPool::connect(&database_url).await.unwrap(); - let profile_repository = - guild_backend::infrastructure::repositories::PostgresProfileRepository::new(pool.clone()); - let auth_service = guild_backend::infrastructure::services::ethereum_address_verification_service::EthereumAddressVerificationService::new(); + let profile_repository = std::sync::Arc::new( + guild_backend::infrastructure::repositories::PostgresProfileRepository::new(pool.clone()) + ); + let auth_service = guild_backend::infrastructure::services::ethereum_address_verification_service::EthereumAddressVerificationService::new(profile_repository.clone()); let state = AppState { - profile_repository: std::sync::Arc::new(profile_repository), + profile_repository, auth_service: std::sync::Arc::new(auth_service), }; let app = test_api(state); diff --git a/backend/tests/profile_tests.rs b/backend/tests/profile_tests.rs index 16c2b3b..ca0a27b 100644 --- a/backend/tests/profile_tests.rs +++ b/backend/tests/profile_tests.rs @@ -60,6 +60,20 @@ mod github_handle_tests { }) .cloned()) } + + async fn get_login_nonce_by_wallet_address( + &self, + _address: &WalletAddress, + ) -> Result, Box> { + Ok(Some(1)) + } + + async fn increment_login_nonce( + &self, + _address: &WalletAddress, + ) -> Result<(), Box> { + Ok(()) + } } #[tokio::test] @@ -72,6 +86,7 @@ mod github_handle_tests { description: None, avatar_url: None, github_login: None, + login_nonce: 1, created_at: chrono::Utc::now(), updated_at: chrono::Utc::now(), }; @@ -102,6 +117,7 @@ mod github_handle_tests { description: None, avatar_url: None, github_login: None, + login_nonce: 1, created_at: chrono::Utc::now(), updated_at: chrono::Utc::now(), }; @@ -133,6 +149,7 @@ mod github_handle_tests { description: None, avatar_url: None, github_login: Some("Alice".into()), + login_nonce: 1, created_at: chrono::Utc::now(), updated_at: chrono::Utc::now(), }; @@ -143,6 +160,7 @@ mod github_handle_tests { description: None, avatar_url: None, github_login: None, + login_nonce: 1, created_at: chrono::Utc::now(), updated_at: chrono::Utc::now(), }; From 6dfbb4490b428428c34bec0017f78f1e7d82e126 Mon Sep 17 00:00:00 2001 From: tusharshah21 Date: Fri, 10 Oct 2025 11:29:46 +0000 Subject: [PATCH 2/3] fixed the issue with the suggestion --- backend/src/application/commands/mod.rs | 1 - backend/src/application/mod.rs | 1 + .../{commands => queries}/get_login_nonce.rs | 2 +- backend/src/application/queries/mod.rs | 1 + .../ethereum_address_verification_service.rs | 13 ++++++------- backend/src/presentation/handlers.rs | 10 +++------- backend/tests/integration_github_handle.rs | 6 +++--- 7 files changed, 15 insertions(+), 19 deletions(-) rename backend/src/application/{commands => queries}/get_login_nonce.rs (99%) create mode 100644 backend/src/application/queries/mod.rs diff --git a/backend/src/application/commands/mod.rs b/backend/src/application/commands/mod.rs index 29342de..ac3cc0c 100644 --- a/backend/src/application/commands/mod.rs +++ b/backend/src/application/commands/mod.rs @@ -1,5 +1,4 @@ pub mod create_profile; pub mod get_all_profiles; -pub mod get_login_nonce; pub mod get_profile; pub mod update_profile; diff --git a/backend/src/application/mod.rs b/backend/src/application/mod.rs index 31002c8..fd62725 100644 --- a/backend/src/application/mod.rs +++ b/backend/src/application/mod.rs @@ -1,2 +1,3 @@ pub mod commands; pub mod dtos; +pub mod queries; diff --git a/backend/src/application/commands/get_login_nonce.rs b/backend/src/application/queries/get_login_nonce.rs similarity index 99% rename from backend/src/application/commands/get_login_nonce.rs rename to backend/src/application/queries/get_login_nonce.rs index 5e33796..2921c8f 100644 --- a/backend/src/application/commands/get_login_nonce.rs +++ b/backend/src/application/queries/get_login_nonce.rs @@ -7,7 +7,7 @@ pub async fn get_login_nonce( address: String, ) -> Result { let wallet_address = WalletAddress(address); - + match profile_repository .get_login_nonce_by_wallet_address(&wallet_address) .await diff --git a/backend/src/application/queries/mod.rs b/backend/src/application/queries/mod.rs new file mode 100644 index 0000000..7e0b400 --- /dev/null +++ b/backend/src/application/queries/mod.rs @@ -0,0 +1 @@ +pub mod get_login_nonce; diff --git a/backend/src/infrastructure/services/ethereum_address_verification_service.rs b/backend/src/infrastructure/services/ethereum_address_verification_service.rs index 35d740c..970dddf 100644 --- a/backend/src/infrastructure/services/ethereum_address_verification_service.rs +++ b/backend/src/infrastructure/services/ethereum_address_verification_service.rs @@ -14,9 +14,7 @@ pub struct EthereumAddressVerificationService { impl EthereumAddressVerificationService { pub fn new(profile_repository: Arc) -> Self { - Self { - profile_repository, - } + Self { profile_repository } } } @@ -28,7 +26,10 @@ impl AuthService for EthereumAddressVerificationService { signature: &str, ) -> Result, Box> { // Create the message with the nonce - let message = format!("Sign this message to authenticate with The Guild.\n\nNonce: {}", challenge.nonce); + let message = format!( + "Sign this message to authenticate with The Guild.\n\nNonce: {}", + challenge.nonce + ); // EIP-191 prefix + keccak256 let msg_hash = hash_message(message); @@ -47,9 +48,7 @@ impl AuthService for EthereumAddressVerificationService { .increment_login_nonce(&wallet_address) .await?; - Ok(Some(AuthResult { - wallet_address, - })) + Ok(Some(AuthResult { wallet_address })) } else { Ok(None) } diff --git a/backend/src/presentation/handlers.rs b/backend/src/presentation/handlers.rs index c02fd9b..dd9f351 100644 --- a/backend/src/presentation/handlers.rs +++ b/backend/src/presentation/handlers.rs @@ -9,10 +9,10 @@ use crate::{ application::{ commands::{ create_profile::create_profile, get_all_profiles::get_all_profiles, - get_login_nonce::get_login_nonce, get_profile::get_profile, - update_profile::update_profile, + get_profile::get_profile, update_profile::update_profile, }, dtos::{CreateProfileRequest, NonceResponse, ProfileResponse, UpdateProfileRequest}, + queries::get_login_nonce::get_login_nonce, }, domain::value_objects::WalletAddress, }; @@ -83,11 +83,7 @@ pub async fn get_nonce_handler( Path(address): Path, ) -> impl IntoResponse { match get_login_nonce(state.profile_repository, address.clone()).await { - Ok(nonce) => Json(NonceResponse { - nonce, - address, - }) - .into_response(), + Ok(nonce) => Json(NonceResponse { nonce, address }).into_response(), Err(e) => (StatusCode::NOT_FOUND, Json(serde_json::json!({"error": e}))).into_response(), } } diff --git a/backend/tests/integration_github_handle.rs b/backend/tests/integration_github_handle.rs index 4c00b44..fa2723c 100644 --- a/backend/tests/integration_github_handle.rs +++ b/backend/tests/integration_github_handle.rs @@ -14,7 +14,7 @@ async fn valid_github_handle_works() { let addr = listener.local_addr().unwrap(); let pool = sqlx::PgPool::connect(&database_url).await.unwrap(); let profile_repository = std::sync::Arc::new( - guild_backend::infrastructure::repositories::PostgresProfileRepository::new(pool.clone()) + guild_backend::infrastructure::repositories::PostgresProfileRepository::new(pool.clone()), ); let auth_service = guild_backend::infrastructure::services::ethereum_address_verification_service::EthereumAddressVerificationService::new(profile_repository.clone()); let state = AppState { @@ -82,7 +82,7 @@ async fn invalid_format_rejected() { let addr = listener.local_addr().unwrap(); let pool = sqlx::PgPool::connect(&database_url).await.unwrap(); let profile_repository = std::sync::Arc::new( - guild_backend::infrastructure::repositories::PostgresProfileRepository::new(pool.clone()) + guild_backend::infrastructure::repositories::PostgresProfileRepository::new(pool.clone()), ); let auth_service = guild_backend::infrastructure::services::ethereum_address_verification_service::EthereumAddressVerificationService::new(profile_repository.clone()); let state = AppState { @@ -157,7 +157,7 @@ async fn conflict_case_insensitive() { let addr = listener.local_addr().unwrap(); let pool = sqlx::PgPool::connect(&database_url).await.unwrap(); let profile_repository = std::sync::Arc::new( - guild_backend::infrastructure::repositories::PostgresProfileRepository::new(pool.clone()) + guild_backend::infrastructure::repositories::PostgresProfileRepository::new(pool.clone()), ); let auth_service = guild_backend::infrastructure::services::ethereum_address_verification_service::EthereumAddressVerificationService::new(profile_repository.clone()); let state = AppState { From c8e7dea80b147998c1a1ced7830d973a9a8379b4 Mon Sep 17 00:00:00 2001 From: tusharshah21 Date: Fri, 10 Oct 2025 18:22:11 +0000 Subject: [PATCH 3/3] fixed the structure as suggested --- ...0dbd5eed42fa868487c84ebef42dfcf695e9ce42725.json} | 12 +++--------- ...59c6815de444a5c6aadc1a9950d9d71f49f52dee768.json} | 12 +++--------- ...590574fa950a74fa68daabb48c80a0a7754e4066987.json} | 12 +++--------- backend/src/application/commands/mod.rs | 2 -- .../{commands => queries}/get_all_profiles.rs | 0 .../application/{commands => queries}/get_profile.rs | 0 backend/src/application/queries/mod.rs | 2 ++ .../repositories/postgres_profile_repository.rs | 12 ++++++------ backend/src/presentation/handlers.rs | 10 +++++----- 9 files changed, 22 insertions(+), 40 deletions(-) rename backend/.sqlx/{query-d23893061ef0e487ff20489fc5f4640e73d70dde72e7412ca265b30db5ac4249.json => query-177358fec702a5f78c1ff0dbd5eed42fa868487c84ebef42dfcf695e9ce42725.json} (75%) rename backend/.sqlx/{query-5b21241db59e84080d36c67abb309e28f8b95cedbd9da3b5a7f2b5ced0505462.json => query-b521c6c7f362753693d7059c6815de444a5c6aadc1a9950d9d71f49f52dee768.json} (77%) rename backend/.sqlx/{query-21d41f830b745d6af6e1319ee36ef0bff9dcf5f133ecb58bf2706104e55d3490.json => query-fd6f338fcae9c81fbf1d7590574fa950a74fa68daabb48c80a0a7754e4066987.json} (74%) rename backend/src/application/{commands => queries}/get_all_profiles.rs (100%) rename backend/src/application/{commands => queries}/get_profile.rs (100%) diff --git a/backend/.sqlx/query-d23893061ef0e487ff20489fc5f4640e73d70dde72e7412ca265b30db5ac4249.json b/backend/.sqlx/query-177358fec702a5f78c1ff0dbd5eed42fa868487c84ebef42dfcf695e9ce42725.json similarity index 75% rename from backend/.sqlx/query-d23893061ef0e487ff20489fc5f4640e73d70dde72e7412ca265b30db5ac4249.json rename to backend/.sqlx/query-177358fec702a5f78c1ff0dbd5eed42fa868487c84ebef42dfcf695e9ce42725.json index 3329f2f..020138d 100644 --- a/backend/.sqlx/query-d23893061ef0e487ff20489fc5f4640e73d70dde72e7412ca265b30db5ac4249.json +++ b/backend/.sqlx/query-177358fec702a5f78c1ff0dbd5eed42fa868487c84ebef42dfcf695e9ce42725.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT address, name, description, avatar_url, github_login, login_nonce, created_at, updated_at\n FROM profiles\n WHERE address = $1\n ", + "query": "\n SELECT address, name, description, avatar_url, github_login, created_at, updated_at\n FROM profiles\n WHERE LOWER(github_login) = LOWER($1)\n ", "describe": { "columns": [ { @@ -30,16 +30,11 @@ }, { "ordinal": 5, - "name": "login_nonce", - "type_info": "Int8" - }, - { - "ordinal": 6, "name": "created_at", "type_info": "Timestamptz" }, { - "ordinal": 7, + "ordinal": 6, "name": "updated_at", "type_info": "Timestamptz" } @@ -55,10 +50,9 @@ true, true, true, - false, true, true ] }, - "hash": "d23893061ef0e487ff20489fc5f4640e73d70dde72e7412ca265b30db5ac4249" + "hash": "177358fec702a5f78c1ff0dbd5eed42fa868487c84ebef42dfcf695e9ce42725" } diff --git a/backend/.sqlx/query-5b21241db59e84080d36c67abb309e28f8b95cedbd9da3b5a7f2b5ced0505462.json b/backend/.sqlx/query-b521c6c7f362753693d7059c6815de444a5c6aadc1a9950d9d71f49f52dee768.json similarity index 77% rename from backend/.sqlx/query-5b21241db59e84080d36c67abb309e28f8b95cedbd9da3b5a7f2b5ced0505462.json rename to backend/.sqlx/query-b521c6c7f362753693d7059c6815de444a5c6aadc1a9950d9d71f49f52dee768.json index 076074a..0e00234 100644 --- a/backend/.sqlx/query-5b21241db59e84080d36c67abb309e28f8b95cedbd9da3b5a7f2b5ced0505462.json +++ b/backend/.sqlx/query-b521c6c7f362753693d7059c6815de444a5c6aadc1a9950d9d71f49f52dee768.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT address, name, description, avatar_url, github_login, login_nonce, created_at, updated_at\n FROM profiles\n ", + "query": "\n SELECT address, name, description, avatar_url, github_login, created_at, updated_at\n FROM profiles\n ", "describe": { "columns": [ { @@ -30,16 +30,11 @@ }, { "ordinal": 5, - "name": "login_nonce", - "type_info": "Int8" - }, - { - "ordinal": 6, "name": "created_at", "type_info": "Timestamptz" }, { - "ordinal": 7, + "ordinal": 6, "name": "updated_at", "type_info": "Timestamptz" } @@ -53,10 +48,9 @@ true, true, true, - false, true, true ] }, - "hash": "5b21241db59e84080d36c67abb309e28f8b95cedbd9da3b5a7f2b5ced0505462" + "hash": "b521c6c7f362753693d7059c6815de444a5c6aadc1a9950d9d71f49f52dee768" } diff --git a/backend/.sqlx/query-21d41f830b745d6af6e1319ee36ef0bff9dcf5f133ecb58bf2706104e55d3490.json b/backend/.sqlx/query-fd6f338fcae9c81fbf1d7590574fa950a74fa68daabb48c80a0a7754e4066987.json similarity index 74% rename from backend/.sqlx/query-21d41f830b745d6af6e1319ee36ef0bff9dcf5f133ecb58bf2706104e55d3490.json rename to backend/.sqlx/query-fd6f338fcae9c81fbf1d7590574fa950a74fa68daabb48c80a0a7754e4066987.json index bb66029..7e5ec3a 100644 --- a/backend/.sqlx/query-21d41f830b745d6af6e1319ee36ef0bff9dcf5f133ecb58bf2706104e55d3490.json +++ b/backend/.sqlx/query-fd6f338fcae9c81fbf1d7590574fa950a74fa68daabb48c80a0a7754e4066987.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT address, name, description, avatar_url, github_login, login_nonce, created_at, updated_at\n FROM profiles\n WHERE LOWER(github_login) = LOWER($1)\n ", + "query": "\n SELECT address, name, description, avatar_url, github_login, created_at, updated_at\n FROM profiles\n WHERE address = $1\n ", "describe": { "columns": [ { @@ -30,16 +30,11 @@ }, { "ordinal": 5, - "name": "login_nonce", - "type_info": "Int8" - }, - { - "ordinal": 6, "name": "created_at", "type_info": "Timestamptz" }, { - "ordinal": 7, + "ordinal": 6, "name": "updated_at", "type_info": "Timestamptz" } @@ -55,10 +50,9 @@ true, true, true, - false, true, true ] }, - "hash": "21d41f830b745d6af6e1319ee36ef0bff9dcf5f133ecb58bf2706104e55d3490" + "hash": "fd6f338fcae9c81fbf1d7590574fa950a74fa68daabb48c80a0a7754e4066987" } diff --git a/backend/src/application/commands/mod.rs b/backend/src/application/commands/mod.rs index ac3cc0c..d5e1704 100644 --- a/backend/src/application/commands/mod.rs +++ b/backend/src/application/commands/mod.rs @@ -1,4 +1,2 @@ pub mod create_profile; -pub mod get_all_profiles; -pub mod get_profile; pub mod update_profile; diff --git a/backend/src/application/commands/get_all_profiles.rs b/backend/src/application/queries/get_all_profiles.rs similarity index 100% rename from backend/src/application/commands/get_all_profiles.rs rename to backend/src/application/queries/get_all_profiles.rs diff --git a/backend/src/application/commands/get_profile.rs b/backend/src/application/queries/get_profile.rs similarity index 100% rename from backend/src/application/commands/get_profile.rs rename to backend/src/application/queries/get_profile.rs diff --git a/backend/src/application/queries/mod.rs b/backend/src/application/queries/mod.rs index 7e0b400..298cba8 100644 --- a/backend/src/application/queries/mod.rs +++ b/backend/src/application/queries/mod.rs @@ -1 +1,3 @@ +pub mod get_all_profiles; pub mod get_login_nonce; +pub mod get_profile; diff --git a/backend/src/infrastructure/repositories/postgres_profile_repository.rs b/backend/src/infrastructure/repositories/postgres_profile_repository.rs index e951f8e..98b5159 100644 --- a/backend/src/infrastructure/repositories/postgres_profile_repository.rs +++ b/backend/src/infrastructure/repositories/postgres_profile_repository.rs @@ -24,7 +24,7 @@ impl ProfileRepository for PostgresProfileRepository { ) -> Result, Box> { let row = sqlx::query!( r#" - SELECT address, name, description, avatar_url, github_login, login_nonce, created_at, updated_at + SELECT address, name, description, avatar_url, github_login, created_at, updated_at FROM profiles WHERE address = $1 "#, @@ -40,7 +40,7 @@ impl ProfileRepository for PostgresProfileRepository { description: r.description, avatar_url: r.avatar_url, github_login: r.github_login, - login_nonce: r.login_nonce, + login_nonce: 0, // Not needed for regular profile queries created_at: r.created_at.unwrap(), updated_at: r.updated_at.unwrap(), })) @@ -49,7 +49,7 @@ impl ProfileRepository for PostgresProfileRepository { async fn find_all(&self) -> Result, Box> { let rows = sqlx::query!( r#" - SELECT address, name, description, avatar_url, github_login, login_nonce, created_at, updated_at + SELECT address, name, description, avatar_url, github_login, created_at, updated_at FROM profiles "#, ) @@ -65,7 +65,7 @@ impl ProfileRepository for PostgresProfileRepository { description: r.description, avatar_url: r.avatar_url, github_login: r.github_login, - login_nonce: r.login_nonce, + login_nonce: 0, // Not needed for regular profile queries created_at: r.created_at.unwrap(), updated_at: r.updated_at.unwrap(), }) @@ -136,7 +136,7 @@ impl ProfileRepository for PostgresProfileRepository { ) -> Result, Box> { let row = sqlx::query!( r#" - SELECT address, name, description, avatar_url, github_login, login_nonce, created_at, updated_at + SELECT address, name, description, avatar_url, github_login, created_at, updated_at FROM profiles WHERE LOWER(github_login) = LOWER($1) "#, @@ -152,7 +152,7 @@ impl ProfileRepository for PostgresProfileRepository { description: r.description, avatar_url: r.avatar_url, github_login: r.github_login, - login_nonce: r.login_nonce, + login_nonce: 0, // Not needed for regular profile queries created_at: r.created_at.unwrap(), updated_at: r.updated_at.unwrap(), })) diff --git a/backend/src/presentation/handlers.rs b/backend/src/presentation/handlers.rs index dd9f351..79ebd72 100644 --- a/backend/src/presentation/handlers.rs +++ b/backend/src/presentation/handlers.rs @@ -7,12 +7,12 @@ use axum::{ use crate::{ application::{ - commands::{ - create_profile::create_profile, get_all_profiles::get_all_profiles, - get_profile::get_profile, update_profile::update_profile, - }, + commands::{create_profile::create_profile, update_profile::update_profile}, dtos::{CreateProfileRequest, NonceResponse, ProfileResponse, UpdateProfileRequest}, - queries::get_login_nonce::get_login_nonce, + queries::{ + get_all_profiles::get_all_profiles, get_login_nonce::get_login_nonce, + get_profile::get_profile, + }, }, domain::value_objects::WalletAddress, };