Skip to content

Commit

Permalink
fix: redirect to password_change only when the password expired
Browse files Browse the repository at this point in the history
  • Loading branch information
damien.rabois committed Jan 19, 2024
1 parent b29e3e0 commit 3d0e0db
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions password_rotate/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@


def redirect_to_change_password(sender, request, user, **kwargs):
messages.error(request, "Password must be changed.")
# set flag for middleware to pick up
request.redirect_to_password_change = True
print("set")
checker = PasswordChecker(request.user)
if checker.is_expired():
messages.error(request, "Password must be changed.")
# set flag for middleware to pick up
request.redirect_to_password_change = True
print("set")


def create_user_handler(sender, instance, created, **kwargs):
Expand Down

0 comments on commit 3d0e0db

Please sign in to comment.