core (memory): stopSession implementation
This commit is contained in:
parent
6a44221a83
commit
3d8d66fa43
1 changed files with 16 additions and 1 deletions
|
|
@ -357,6 +357,20 @@ class Memory(object):
|
|||
|
||||
return self.host.initialised.addCallback(backendInitialised)
|
||||
|
||||
def stopSession(self, profile):
|
||||
"""Delete a profile session
|
||||
|
||||
@param profile: %(doc_profile)s
|
||||
"""
|
||||
if self.host.isConnected(profile):
|
||||
log.debug(u"Disconnecting profile because of session stop")
|
||||
self.host.disconnect(profile)
|
||||
self.auth_sessions.profileDelUnique(profile)
|
||||
try:
|
||||
self._entities_cache[profile]
|
||||
except KeyError:
|
||||
log.warning(u"Profile was not in cache")
|
||||
|
||||
def _isSessionStarted(self, profile_key):
|
||||
return self.isSessionStarted(self.getProfileName(profile_key))
|
||||
|
||||
|
|
@ -374,6 +388,7 @@ class Memory(object):
|
|||
@param password (unicode): the SàT profile password
|
||||
@param profile: %(doc_profile)s
|
||||
@return (D): a deferred None in case of success, a failure otherwise.
|
||||
@raise exceptions.PasswordError: the password does not match
|
||||
"""
|
||||
session_data = self.auth_sessions.profileGetUnique(profile)
|
||||
if not password and session_data:
|
||||
|
|
@ -385,7 +400,7 @@ class Memory(object):
|
|||
def check_result(result):
|
||||
if not result:
|
||||
log.warning(u'Authentication failure of profile {}'.format(profile))
|
||||
raise exceptions.PasswordError(u"The provided profile password doesn't match.")
|
||||
raise failure.Failure(exceptions.PasswordError(u"The provided profile password doesn't match."))
|
||||
if not session_data: # avoid to create two profile sessions when password if specified
|
||||
return self.newAuthSession(password, profile)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue