feat: add support for user registration toggle and Traefik integration in Docker setup
This commit is contained in:
@@ -73,6 +73,10 @@ async fn register(
|
||||
State(state): State<AppState>,
|
||||
Json(payload): Json<RegisterRequest>,
|
||||
) -> Result<impl IntoResponse, ApiError> {
|
||||
if !state.config.allow_registration {
|
||||
return Err(ApiError::Forbidden("Registration is disabled".to_string()));
|
||||
}
|
||||
|
||||
let password_hash = infra::auth::hash_password(payload.password.as_ref());
|
||||
|
||||
let user = state
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
use axum::{Json, Router, routing::get};
|
||||
use axum::{Json, Router, extract::State, routing::get};
|
||||
use std::sync::Arc;
|
||||
use crate::config::Config;
|
||||
use crate::dto::ConfigResponse;
|
||||
use crate::state::AppState;
|
||||
|
||||
@@ -6,8 +8,8 @@ pub fn router() -> Router<AppState> {
|
||||
Router::new().route("/", get(get_config))
|
||||
}
|
||||
|
||||
async fn get_config() -> Json<ConfigResponse> {
|
||||
async fn get_config(State(config): State<Arc<Config>>) -> Json<ConfigResponse> {
|
||||
Json(ConfigResponse {
|
||||
allow_registration: true, // Default to true for template
|
||||
allow_registration: config.allow_registration,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user