mirror of
https://github.com/N4S4/synology-api.git
synced 2025-08-13 14:46:24 +00:00
Delete duplicated in core_sys_info.py:
- imports - users_info(), pasword_policy(), password_expiry() --> now in core_user.py Move password_confirm() from core_sys_info.py to core_user.py Update README.md Update requirements.txt --> Added cryptography module
This commit is contained in:
@ -558,4 +558,40 @@ class User(base_api.BaseApi):
|
||||
"enable_mail_notification": enable_mail_notification,
|
||||
"never_expired_list": json.dumps(never_expired_list)
|
||||
}
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
|
||||
def password_confirm(self, password: str) -> dict[str, object] | str:
|
||||
"""Issues a passowrd/session comparison to ensure the given password matches the auth of the current session.
|
||||
|
||||
This is needed by some APIs as a confirmation method, for example, when creating/modifying a scheduled task with root permissions.
|
||||
Please note that the password will be sent in plain text, just like in the base auth method.
|
||||
|
||||
Args:
|
||||
password (str):
|
||||
The password with which the session was initiated.
|
||||
|
||||
Returns:
|
||||
dict|str:
|
||||
A dictionary containing a `SynoConfirmPWToken`, or an error message.
|
||||
|
||||
Example return:
|
||||
{
|
||||
"data": {
|
||||
"SynoConfirmPWToken": "xxxxx"
|
||||
},
|
||||
"success": true
|
||||
}
|
||||
"""
|
||||
api_name = 'SYNO.Core.User.PasswordConfirm'
|
||||
info = self.core_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'auth'}
|
||||
# Using https
|
||||
if self.session._secure:
|
||||
req_param.update({"password": password})
|
||||
# Using http and self encrypted
|
||||
else:
|
||||
req_param.update(self.session.encrypt_params({"password": password}))
|
||||
|
||||
return self.request_data(api_name, api_path, req_param, method="post")
|
Reference in New Issue
Block a user