Enhanced the user creation way.
This commit is contained in:
@@ -111,8 +111,8 @@ During installation, you will be prompted to configure the following variables:
|
||||
|
||||
### 3. HAS_LOCAL_DBS
|
||||
Determines how the middleware connects to databases:
|
||||
- **Enter `0`** – If the database is hosted on a remote server.
|
||||
- **Enter `1`** – If the database runs on the same machine.
|
||||
- **Enter `0`** – If all the databases are hosted on a remote server.
|
||||
- **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.
|
||||
|
||||
|
||||
@@ -112,7 +112,6 @@ We can't execute commands inside it, you can run it with:
|
||||
|
||||
# Execute the command in the container
|
||||
OUTPUT=$(docker exec "$CONTAINER_NAME" bash -c "$COMMAND" 2>&1)
|
||||
|
||||
local EXIT_CODE=$?
|
||||
|
||||
# Check if the command succeeded
|
||||
@@ -174,7 +173,7 @@ create_user(){
|
||||
local RETURN_CODE=$?
|
||||
|
||||
if [[ $RETURN_CODE -eq 0 ]]; then
|
||||
print_header $EXECUTION_MESSAGE
|
||||
print_header "$EXECUTION_MESSAGE"
|
||||
else
|
||||
print_header "Couldn't create the user due to the above error."
|
||||
fi
|
||||
|
||||
@@ -74,15 +74,20 @@ def create_secret():
|
||||
|
||||
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():
|
||||
print("> Invalid username. Please use alphanumerical characters only.")
|
||||
return
|
||||
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.")
|
||||
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_:
|
||||
print("> Invalid role. Please enter 'admin' or 'user'.")
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user