Users
Bases: UserModel
User class representing a user in the system.
create(name, password)
classmethod
¶
Creates a new user with the given name and password.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The username for the new user. |
required |
password
|
str
|
The password for the new user. |
required |
Raises:
Type | Description |
---|---|
AlreadyExistsException
|
If the username already exists. |
InvalidUsernameException
|
If the username is invalid. |
Returns:
Name | Type | Description |
---|---|---|
User |
User
|
The created user instance. |
Source code in svs_core/users/user.py
is_username_valid(username)
staticmethod
¶
Validates the username based on specific criteria.
The username needs to be a valid UNIX username.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
username
|
str
|
The username to validate. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the username is valid, False otherwise. |
Source code in svs_core/users/user.py
is_password_valid(password)
staticmethod
¶
Validates the password based on specific criteria.
The password must be at least 8 characters long.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
password
|
str
|
The password to validate. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the password is valid, False otherwise. |
Source code in svs_core/users/user.py
username_exists(username)
classmethod
¶
Checks if a username already exists in the database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
username
|
str
|
The username to check. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the username exists, False otherwise. |
Source code in svs_core/users/user.py
check_password(password)
¶
Checks if the provided password matches the user's password.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
password
|
str
|
The password to check. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if the password matches, False otherwise. |
Source code in svs_core/users/user.py
delete()
¶
Deletes the user from the database and removes associated resources.
This includes deleting the system user and Docker network associated with the user.