Include require auth middleware and login route

This commit is contained in:
GW_MC
2025-12-18 18:25:57 +08:00
parent b0c11c7c67
commit ccd8bc7aa1
15 changed files with 326 additions and 39 deletions

View File

@@ -13,7 +13,10 @@ use crate::{
log,
routes::{self, AppService, AppState},
services::{
auth::{authentication::AuthenticationServiceImpl, user::UserServiceImpl},
auth::{
authentication::{AuthenticationServiceImpl, strategies::password::PasswordStrategy},
user::UserServiceImpl,
},
settings::SettingsService,
},
tasks,
@@ -129,9 +132,15 @@ fn get_app_state(
database_connection: db_connection.clone(),
service: Arc::new(AppService {
settings: Arc::new(SettingsService::new(db_connection.clone())),
authentication: Arc::new(AuthenticationServiceImpl::new(
settings.auth.jwt_secret.clone(),
)),
auth_state: routes::AuthState {
strategy: routes::AuthStrategy {
password: Arc::new(PasswordStrategy::new(db_connection.clone())),
},
authentication: Arc::new(AuthenticationServiceImpl::new(
settings.auth.jwt_secret.clone(),
)),
user: Arc::new(UserServiceImpl::new(db_connection.clone())),
},
user: Arc::new(UserServiceImpl::new(db_connection.clone())),
}),
}