def requestAvatarId(self, credentials):
"""
Return the avatar id of the avatar which can be accessed using the
given credentials.
credentials will be an object with username and password tags. We
need to raise an error to indicate failure or return a username to
indicate success. requestAvatar will then be called with the
avatar id we returned.
"""
try:
session = yield self.facadeClient.authenticateUserWithPassword(
credentials.username, credentials.password)
except (TPasswordIncorrect, TNoSuchUser):
unauthorizedLogin = error.UnauthorizedLogin('Invalid credentials')
log.msg('Bad credentials: %r:%r' %
(credentials.username, '<sanitized>'))
raise unauthorizedLogin
except Exception, e:
log.msg('requestAvatarId exception authenticating %r/%r.' %
(credentials.username, '<sanitized>'))
log.err(e)
raise
else:
defer.returnValue(session)
评论列表
文章目录