diff options
author | Rob Cresswell <robert.cresswell@outlook.com> | 2016-09-27 14:18:57 +0000 |
---|---|---|
committer | Rob Cresswell <robert.cresswell@outlook.com> | 2016-09-27 14:19:22 +0000 |
commit | 61500ab57c7d84f75cd30efa3ac988c32214689f (patch) | |
tree | 59ab09c0d29261d419cff7069717c08c5b013179 | |
parent | 03a6db3074e605b901ba68d210bc58f3769a9560 (diff) | |
download | django_openstack_auth-61500ab57c7d84f75cd30efa3ac988c32214689f.tar.gz |
Revert "Add is_authenticated and is_anonymous properties"
Reverting before release. See
http://eavesdrop.openstack.org/irclogs/%23openstack-release/%23openstack-release.2016-09-27.log.html#t2016-09-27T12:25:00
from 12:25 to 14:15.
This reverts commit 03a6db3074e605b901ba68d210bc58f3769a9560.
Change-Id: I4e50dc38f8b41d5730d8f613dd24d7384ca455e5
-rw-r--r-- | openstack_auth/user.py | 75 |
1 files changed, 29 insertions, 46 deletions
diff --git a/openstack_auth/user.py b/openstack_auth/user.py index fba75e7..c9200f4 100644 --- a/openstack_auth/user.py +++ b/openstack_auth/user.py @@ -14,11 +14,9 @@ import hashlib import logging -import django from django.conf import settings from django.contrib.auth import models from django.db import models as db_models -from django.utils import deprecation from keystoneauth1 import exceptions as keystone_exceptions from keystoneclient.common import cms as keystone_cms import six @@ -263,50 +261,35 @@ class User(models.AbstractBaseUser, models.AnonymousUser): return None return not utils.is_token_valid(self.token, margin) - if django.VERSION >= (1, 10): - @property - def is_authenticated(self): - """Checks for a valid authentication.""" - if (self.token is not None and utils.is_token_valid(self.token)): - return deprecation.CallableTrue - else: - return deprecation.CallableFalse - - @property - def is_anonymous(self): - """Return if the user is not authenticated. - - Returns ``True`` if not authenticated,``False`` otherwise. - """ - return deprecation.CallableBool(not self.is_authenticated) - else: - def is_authenticated(self, margin=None): - """Checks for a valid authentication. - - :param margin: - A security time margin in seconds before end of authentication. - Will return ``False`` if authentication ends in less than - ``margin`` seconds of time. - A default margin can be set by the TOKEN_TIMEOUT_MARGIN in the - django settings. - """ - return (self.token is not None and - utils.is_token_valid(self.token, margin)) - - def is_anonymous(self, margin=None): - """Return if the user is not authenticated. - - Returns ``True`` if not authenticated,``False`` otherwise. - - :param margin: - A security time margin in seconds before end of an eventual - authentication. - Will return ``True`` even if authenticated but that - authentication ends in less than ``margin`` seconds of time. - A default margin can be set by the TOKEN_TIMEOUT_MARGIN in the - django settings. - """ - return not self.is_authenticated(margin) + def is_authenticated(self, margin=None): + """Checks for a valid authentication. + + :param margin: + A security time margin in seconds before end of authentication. + Will return ``False`` if authentication ends in less than ``margin`` + seconds of time. + A default margin can be set by the TOKEN_TIMEOUT_MARGIN in the + django settings. + + """ + return (self.token is not None and + utils.is_token_valid(self.token, margin)) + + def is_anonymous(self, margin=None): + """Return if the user is not authenticated. + + Returns ``True`` if not authenticated,``False`` otherwise. + + :param margin: + A security time margin in seconds before end of an eventual + authentication. + Will return ``True`` even if authenticated but that authentication + ends in less than ``margin`` seconds of time. + A default margin can be set by the TOKEN_TIMEOUT_MARGIN in the + django settings. + + """ + return not self.is_authenticated(margin) @property def is_active(self): |