Incorrect url passed to BaseApiClient which already has base_url.

Also added getter and setter of failed login count, although that is
yet to be synced with api.
This commit is contained in:
Adam Shimali
2016-01-22 09:22:18 +00:00
committed by Chris Hill-Scott
parent 3b19c9b853
commit 3e19fa50d2

View File

@@ -15,7 +15,7 @@ class UserApiClient(BaseAPIClient):
self.base_url = app.config['API_HOST_NAME']
self.client_id = app.config['ADMIN_CLIENT_USER_NAME']
self.secret = app.config['ADMIN_CLIENT_SECRET']
self.failed_login_count = app.config["MAX_FAILED_LOGIN_COUNT"]
self.user_max_failed_login_count = app.config["MAX_FAILED_LOGIN_COUNT"]
def register_user(self, name, email_address, mobile_number, password):
data = {
@@ -33,8 +33,7 @@ class UserApiClient(BaseAPIClient):
return User(user_data['data'], max_failed_login_count=self.failed_login_count)
def get_users(self):
url = "/user".format()
users_data = self.get(url)['data']
users_data = self.get("/user")['data']
users = []
for user in users_data:
users.append(User(user, max_failed_login_count=self.failed_login_count))
@@ -76,6 +75,7 @@ class User(object):
def __init__(self, fields, max_failed_login_count=3):
self.fields = fields
self.max_failed_login_count = max_failed_login_count
self._failed_login_count = 0
@property
def id(self):
@@ -114,11 +114,19 @@ class User(object):
def state(self, state):
self.fields['state'] = state
@property
def failed_login_count(self):
return self._failed_login_count
@failed_login_count.setter
def failed_login_count(self, num):
self._failed_login_count += num
def is_anonymous(self):
return False
def is_locked(self):
return self.fields.get('failed_login_count') > self.max_failed_login_count
return self.failed_login_count > self.max_failed_login_count
def serialize(self):
return self.fields