Add possibility to log out (clear session cookie)
This commit is contained in:
parent
14b06560e6
commit
3f46bf74d8
|
@ -67,6 +67,7 @@ class Client:
|
|||
def __init__(self, sympa_url: str):
|
||||
self.sympa_url = sympa_url
|
||||
self.zeep = ZeepClient(sympa_url + "/wsdl", settings=ZeepSettings(strict=False))
|
||||
self.cookie = None
|
||||
|
||||
def login(self, email: str, password: str) -> None:
|
||||
"""
|
||||
|
@ -79,8 +80,17 @@ class Client:
|
|||
if self.check_cookie() != email:
|
||||
# FIXME Better exception
|
||||
raise Exception("Unknown error: given cookie is invalid")
|
||||
self.email = email
|
||||
print("Successfully authenticated!")
|
||||
|
||||
def logout(self):
|
||||
"""
|
||||
Clear cookie
|
||||
"""
|
||||
self.cookie = None
|
||||
self.email = None
|
||||
self.zeep.settings.extra_http_headers = []
|
||||
|
||||
def check_cookie(self) -> str:
|
||||
"""
|
||||
From the current cookie, retrieve the email address.
|
||||
|
|
Loading…
Reference in New Issue