Skip to content

KeyError '_password_policies_change_required' #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
xusy2k opened this issue Mar 16, 2015 · 7 comments
Closed

KeyError '_password_policies_change_required' #31

xusy2k opened this issue Mar 16, 2015 · 7 comments

Comments

@xusy2k
Copy link
Contributor

xusy2k commented Mar 16, 2015

If I set PASSWORD_USE_HISTORY to False I always get this exception

@tarak
Copy link
Owner

tarak commented Mar 17, 2015

Can you provide the whole stack trace?

@xusy2k
Copy link
Contributor Author

xusy2k commented Mar 17, 2015

Environment:

Request Method: GET
Request URL: http://localhost:8000/admin/

Django Version: 1.5.12
Python Version: 2.7.6
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.admindocs',
'password_policies')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'password_policies.middleware.PasswordChangeMiddleware')

Traceback:
File "/home/xus/.virtualenvs/test_django/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response

  1.                 response = middleware_method(request)
    
    File "/home/xus/.virtualenvs/test_django/local/lib/python2.7/site-packages/password_policies/middleware.py" in process_request
  2.         return self._redirect(request)
    
    File "/home/xus/.virtualenvs/test_django/local/lib/python2.7/site-packages/password_policies/middleware.py" in _redirect
  3.     if request.session[self.required]:
    
    File "/home/xus/.virtualenvs/test_django/local/lib/python2.7/site-packages/django/contrib/sessions/backends/base.py" in getitem
  4.     return self._session[key]
    

Exception Type: KeyError at /admin/
Exception Value: '_password_policies_change_required'

@tarak
Copy link
Owner

tarak commented Mar 17, 2015

Thx! Can you try to remove the 'password_policies.middleware.PasswordChangeMiddleware'. Won't work anyway if you set PASSWORD_USE_HISTORY to false I think...

The middleware is not very reliable and needs to be rewritten.

Is there a reason why you need the middleware and disable the usage of the password history at the same time?

@xusy2k
Copy link
Contributor Author

xusy2k commented Mar 17, 2015

Thx! It worked!
Only reason for need the middleware and disable the usage of the password history is for testing PASSWORD_CHECK_ONLY_AT_LOGIN = False feature, but I don't want to use historic passwords.
Finally I set PASSWORD_HISTORY_COUNT = 1

@tarak
Copy link
Owner

tarak commented Mar 21, 2015

So this issue could be closed?

@xusy2k
Copy link
Contributor Author

xusy2k commented Mar 21, 2015

Yes!, It worked for me

@tarak
Copy link
Owner

tarak commented Apr 5, 2015

Closing as it seems to work for @xusy2k.

@tarak tarak closed this as completed Apr 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants