Skip to content

Commit

Permalink
chore: remove unused code in the PasswordHistoryManager
Browse files Browse the repository at this point in the history
  • Loading branch information
damien.rabois committed Feb 1, 2024
1 parent f9ab2dc commit 0908c33
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 39 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file.

## [0.0.7] - 2024-02-01

### Miscellaneous Tasks

- Improve display in the admin
- Remove unused code in the `PasswordHistoryManager`

## [0.0.6] - 2024-02-01

### Bug Fixes
Expand Down
39 changes: 0 additions & 39 deletions password_rotate/managers.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
from datetime import timedelta

from django.db import models
from django.utils import timezone
from django.contrib.auth.hashers import identify_hasher
from django.core.exceptions import ObjectDoesNotExist

from django.conf import settings


Expand All @@ -27,26 +22,6 @@ def delete_expired(self, user, offset=None):
entry = qs[offset:offset + 1].get()
qs.filter(created__lte=entry.created).delete()

def change_required(self, user):
"""
Checks if the user needs to change his/her password.
:arg object user: A :class:`~django.contrib.auth.models.User` instance.
:returns: ``True`` if the user needs to change his/her password, ``False`` otherwise.
:rtype: bool
"""
newest = self.get_newest(user)
if newest:
last_change = newest.created
else:
# TODO: Do not rely on this property!
last_change = user.date_joined
d = timedelta(seconds=settings.PASSWORD_DURATION_SECONDS)
expiry = timezone.now() - d
if last_change < expiry:
return True
return False

def check_password(self, user, raw_password):
"""
Compares a raw (UNENCRYPTED!!!) password to entries in the users's
Expand All @@ -68,17 +43,3 @@ def check_password(self, user, raw_password):
result = False
break
return result

def get_newest(self, user):
"""
Gets the newest password history entry.
:arg object user: A :class:`~django.contrib.auth.models.User` instance.
:returns: A :class:`~password_rotate.models.PasswordHistory` instance
if found, ``None`` if not.
"""
try:
entry = self.filter(user=user).latest()
except ObjectDoesNotExist:
return None
return entry

0 comments on commit 0908c33

Please sign in to comment.