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,8 +96,12 @@ class Users_Controller:
|
|||||||
users_helper.update_user(user_id, up_data)
|
users_helper.update_user(user_id, up_data)
|
||||||
|
|
||||||
@staticmethod
|
@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)
|
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
|
@staticmethod
|
||||||
def remove_user(user_id):
|
def remove_user(user_id):
|
||||||
|
@ -147,7 +147,7 @@ class helper_users:
|
|||||||
return user
|
return user
|
||||||
|
|
||||||
@staticmethod
|
@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:
|
if password is not None:
|
||||||
pw_enc = helper.encode_pass(password)
|
pw_enc = helper.encode_pass(password)
|
||||||
else:
|
else:
|
||||||
@ -161,6 +161,17 @@ class helper_users:
|
|||||||
Users.created: helper.get_time_as_string()
|
Users.created: helper.get_time_as_string()
|
||||||
}).execute()
|
}).execute()
|
||||||
return user_id
|
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
|
@staticmethod
|
||||||
def update_user(user_id, up_data=None):
|
def update_user(user_id, up_data=None):
|
||||||
|
Loading…
Reference in New Issue
Block a user