From 5f52c0d3d692bb882450cfb995dc8a527c06ded7 Mon Sep 17 00:00:00 2001 From: Adam Shimali Date: Thu, 28 Jan 2016 15:34:02 +0000 Subject: [PATCH] Inherit from flask usermixin for default implementation of is_authenticated and is_anonymous --- app/notify_client/user_api_client.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/app/notify_client/user_api_client.py b/app/notify_client/user_api_client.py index a083310d3..7e318c20a 100644 --- a/app/notify_client/user_api_client.py +++ b/app/notify_client/user_api_client.py @@ -4,6 +4,8 @@ from client.errors import ( InvalidResponse ) +from flask.ext.login import UserMixin + class UserApiClient(BaseAPIClient): def __init__(self, base_url=None, client_id=None, secret=None): @@ -84,7 +86,7 @@ class UserApiClient(BaseAPIClient): raise e -class User(object): +class User(UserMixin): def __init__(self, fields, max_failed_login_count=3): self._id = fields.get('id') self._name = fields.get('name') @@ -98,9 +100,6 @@ class User(object): def get_id(self): return self.id - def is_authenticated(self): - return True - def is_active(self): return self.state == 'active' @@ -160,9 +159,6 @@ class User(object): def failed_login_count(self, num): self._failed_login_count += num - def is_anonymous(self): - return False - def is_locked(self): return self.failed_login_count >= self.max_failed_login_count