Enhanced the user creation way.

This commit is contained in:
2025-04-06 12:11:43 +03:00
parent 91459ddabe
commit 9ffbe59356
3 changed files with 12 additions and 8 deletions

View File

@@ -111,8 +111,8 @@ During installation, you will be prompted to configure the following variables:
### 3. HAS_LOCAL_DBS ### 3. HAS_LOCAL_DBS
Determines how the middleware connects to databases: Determines how the middleware connects to databases:
- **Enter `0`** If the database is hosted on a remote server. - **Enter `0`** If all the databases are hosted on a remote server.
- **Enter `1`** If the database runs on the same machine. - **Enter `1`** If one or more of the database runs on the same machine.
> **Note:** By default, Docker containers operate on an isolated network. If your database is local, the middleware must be configured to run on the same network to ensure connectivity. > **Note:** By default, Docker containers operate on an isolated network. If your database is local, the middleware must be configured to run on the same network to ensure connectivity.

View File

@@ -112,7 +112,6 @@ We can't execute commands inside it, you can run it with:
# Execute the command in the container # Execute the command in the container
OUTPUT=$(docker exec "$CONTAINER_NAME" bash -c "$COMMAND" 2>&1) OUTPUT=$(docker exec "$CONTAINER_NAME" bash -c "$COMMAND" 2>&1)
local EXIT_CODE=$? local EXIT_CODE=$?
# Check if the command succeeded # Check if the command succeeded
@@ -174,7 +173,7 @@ create_user(){
local RETURN_CODE=$? local RETURN_CODE=$?
if [[ $RETURN_CODE -eq 0 ]]; then if [[ $RETURN_CODE -eq 0 ]]; then
print_header $EXECUTION_MESSAGE print_header "$EXECUTION_MESSAGE"
else else
print_header "Couldn't create the user due to the above error." print_header "Couldn't create the user due to the above error."
fi fi

View File

@@ -74,15 +74,20 @@ def create_secret():
async def create_user_script_async(username:str|None=None, role_input:str|None=None): async def create_user_script_async(username:str|None=None, role_input:str|None=None):
username = username.strip() if username else input("Enter username: ").strip() if not (username and role_input):
username = input("Enter username: ")
role_input = input("Enter role (admin/user): ")
print('\n')
username = username.strip()
role_input = role_input.strip().lower()
if not username.isalnum(): if not username.isalnum():
print("> Invalid username. Please use alphanumerical characters only.") print("> Invalid username. Please use alphanumerical characters only.")
return return
if not re.match("[a-zA-Z]{1}[a-zA-Z0-0-9]{,15}", username): if not re.match("[a-zA-Z]{1}[a-zA-Z0-0-9]{,15}", username):
print("> Invalid username. Please use english characters and numbers only.") print("> Invalid username. Please use english characters and numbers only.")
return return
role_input = role_input.strip().lower() if role_input else input("Enter role (admin/user): ").strip().lower()
print('\n')
if role_input not in UserRole._value2member_map_: if role_input not in UserRole._value2member_map_:
print("> Invalid role. Please enter 'admin' or 'user'.") print("> Invalid role. Please enter 'admin' or 'user'.")
return return