Add logout method (#79)

This commit is contained in:
Quentame
2020-10-20 23:40:57 +02:00
committed by GitHub
parent 4132155ab8
commit c9b8de00c5
2 changed files with 10 additions and 2 deletions

View File

@ -124,7 +124,7 @@ class SynologyDSM:
"""Gets available API infos from the NAS."""
return self._apis
def login(self, otp_code: str = None):
def login(self, otp_code: str = None) -> bool:
"""Create a logged session."""
# First reset the session
self._debuglog("Creating new session")
@ -176,7 +176,13 @@ class SynologyDSM:
self._information = SynoDSMInformation(self)
self._information.update()
return True
return result["success"]
def logout(self) -> bool:
"""Log out of the session."""
result = self.get(API_AUTH, "logout")
self._session = None
return result["success"]
@property
def device_token(self) -> str:

View File

@ -21,3 +21,5 @@ DSM_6_AUTH_LOGIN_2SA_OTP = {
},
"success": True,
}
DSM_6_AUTH_LOGOUT = {"success": True}