forked from jsxc/xmpp-cloud-auth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
isuser.py
32 lines (28 loc) · 1.02 KB
/
isuser.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import logging
class isuser:
def __init__(self, reqdata):
self.reqdata = reqdata
def isuser_verbose(self):
success, code, response, text = self.verbose_cloud_request({
'operation': 'isuser',
'username': self.username,
'domain': self.authDomain
})
return success, code, response
def isuser_cloud(self):
response = self.cloud_request({
'operation': 'isuser',
'username': self.username,
'domain': self.authDomain
})
try:
return response and response['result'] == 'success' and response['data']['isUser']
except KeyError:
logging.error('Request for %s@%s returned malformed response: %s'
% (self.username, self.domain, str(response)))
return False
def isuser(self):
if self.isuser_cloud():
logging.info('Cloud says user %s@%s exists' % (self.username, self.domain))
return True
return False