diff --git a/backend/src/infrastructure/services/ethereum_address_verification_service.rs b/backend/src/infrastructure/services/ethereum_address_verification_service.rs index 62e64ce..e8ff93f 100644 --- a/backend/src/infrastructure/services/ethereum_address_verification_service.rs +++ b/backend/src/infrastructure/services/ethereum_address_verification_service.rs @@ -48,3 +48,32 @@ impl AuthService for EthereumAddressVerificationService { } } } + +// Use the following to bypass signature verification + +pub struct MockEthereumAddressVerificationService {} + +impl MockEthereumAddressVerificationService { + pub fn new() -> Self { + Self {} + } +} + +impl Default for MockEthereumAddressVerificationService { + fn default() -> Self { + Self::new() + } +} + +#[async_trait] +impl AuthService for MockEthereumAddressVerificationService { + async fn verify_signature( + &self, + _challenge: &AuthChallenge, + _signature: &str, + ) -> Result, Box> { + Ok(Some(AuthResult { + wallet_address: WalletAddress("0x2581aAa94299787a8A588B2Fceb161A302939E28".to_string()), + })) + } +} diff --git a/backend/src/main.rs b/backend/src/main.rs index 15574f9..fc6012e 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -1,5 +1,5 @@ use presentation::api::create_app; -use std::net::SocketAddr; +use std::{env, net::SocketAddr}; use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; pub mod application; @@ -9,7 +9,8 @@ pub mod presentation; #[tokio::main] async fn main() -> anyhow::Result<()> { - // Initialize tracing + let database_url = env::var("DATABASE_URL").expect("DATABASE_URL must be set"); + tracing_subscriber::registry() .with( tracing_subscriber::EnvFilter::try_from_default_env() @@ -18,26 +19,19 @@ async fn main() -> anyhow::Result<()> { .with(tracing_subscriber::fmt::layer()) .init(); - // Load environment variables dotenvy::dotenv().ok(); - // For development, create a mock pool - // TODO: Set up real database connection - let pool = sqlx::PgPool::connect("postgresql://localhost/guild_dev") + let pool = sqlx::PgPool::connect(&database_url) .await .unwrap_or_else(|_| { tracing::warn!("Could not connect to database, using mock pool"); - // Return a mock pool for now panic!("Database connection required"); }); - // Run migrations sqlx::migrate!("./migrations").run(&pool).await?; - // Create the app let app = create_app(pool).await; - // Run the server let addr = SocketAddr::from(([0, 0, 0, 0], 3001)); tracing::info!("Server listening on {}", addr); diff --git a/backend/src/presentation/api.rs b/backend/src/presentation/api.rs index e8ba67c..ea83aa2 100644 --- a/backend/src/presentation/api.rs +++ b/backend/src/presentation/api.rs @@ -32,7 +32,7 @@ pub async fn create_app(pool: sqlx::PgPool) -> Router { }; let protected = Router::new() - .route("/profiles/:address", post(create_profile_handler)) + .route("/profiles/", post(create_profile_handler)) .route("/profiles/:address", get(get_profile_handler)) .route("/profiles/:address", put(update_profile_handler));