From 5ecb71ce9d1025c8cee2b38df05ea3e60e64fed2 Mon Sep 17 00:00:00 2001 From: Ethan Girouard Date: Sun, 24 Nov 2024 14:36:56 -0500 Subject: [PATCH] Return error on /api/signup if signup disabled --- src/auth.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/auth.rs b/src/auth.rs index cea063b..f28eeb4 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -19,6 +19,11 @@ use crate::users::UserCredentials; /// Returns a Result with the error message if the user could not be created #[server(endpoint = "signup")] pub async fn signup(new_user: User) -> Result<(), ServerFnError> { + // Check LIBRETUNES_DISABLE_SIGNUP env var + if std::env::var("LIBRETUNES_DISABLE_SIGNUP").is_ok_and(|v| v == "true") { + return Err(ServerFnError::::ServerError("Signup is disabled".to_string())); + } + use crate::users::create_user; // Ensure the user has no id, and is not a self-proclaimed admin