mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Add functions for importing 3.x users, require passwords when adding users
This commit is contained in:
parent
ccd0bc8e8f
commit
7c822b715a
@ -96,9 +96,13 @@ class Users_Controller:
|
||||
users_helper.update_user(user_id, up_data)
|
||||
|
||||
@staticmethod
|
||||
def add_user(username, password=None, email="default@example.com", enabled: bool = True, superuser: bool = False):
|
||||
def add_user(username, password, email="default@example.com", enabled: bool = True, superuser: bool = False):
|
||||
return users_helper.add_user(username, password=password, email=email, enabled=enabled, superuser=superuser)
|
||||
|
||||
@staticmethod
|
||||
def add_rawpass_user(username, password, email="default@example.com", enabled: bool = True, superuser: bool = False):
|
||||
return users_helper.add_rawpass_user(username, password=password, email=email, enabled=enabled, superuser=superuser)
|
||||
|
||||
@staticmethod
|
||||
def remove_user(user_id):
|
||||
return users_helper.remove_user(user_id)
|
||||
|
@ -147,7 +147,7 @@ class helper_users:
|
||||
return user
|
||||
|
||||
@staticmethod
|
||||
def add_user(username: str, password: Optional[str] = None, email: Optional[str] = None, enabled: bool = True, superuser: bool = False) -> str:
|
||||
def add_user(username: str, password: str = None, email: Optional[str] = None, enabled: bool = True, superuser: bool = False) -> str:
|
||||
if password is not None:
|
||||
pw_enc = helper.encode_pass(password)
|
||||
else:
|
||||
@ -162,6 +162,17 @@ class helper_users:
|
||||
}).execute()
|
||||
return user_id
|
||||
|
||||
@staticmethod
|
||||
def add_rawpass_user(username: str, password: str = None, email: Optional[str] = None, enabled: bool = True, superuser: bool = False) -> str:
|
||||
user_id = Users.insert({
|
||||
Users.username: username.lower(),
|
||||
Users.password: password,
|
||||
Users.email: email,
|
||||
Users.enabled: enabled,
|
||||
Users.superuser: superuser,
|
||||
Users.created: helper.get_time_as_string()
|
||||
}).execute()
|
||||
|
||||
@staticmethod
|
||||
def update_user(user_id, up_data=None):
|
||||
if up_data is None:
|
||||
|
Loading…
Reference in New Issue
Block a user