Skip to content

Commit bee961f

Browse files
teuneboonPsykopear
authored andcommitted
If AccessToken/Grant had, for w/e reason, no "expires", is_expired check would fail with a TypeError(can't compare datetime.datetime to NoneType)
1 parent 54fa0aa commit bee961f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

oauth2_provider/models.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ def is_expired(self):
157157
"""
158158
Check token expiration with timezone awareness
159159
"""
160+
if not self.expires:
161+
return True
162+
160163
return timezone.now() >= self.expires
161164

162165
def redirect_uri_allowed(self, uri):
@@ -198,6 +201,9 @@ def is_expired(self):
198201
"""
199202
Check token expiration with timezone awareness
200203
"""
204+
if not self.expires:
205+
return True
206+
201207
return timezone.now() >= self.expires
202208

203209
def allow_scopes(self, scopes):

0 commit comments

Comments
 (0)