django-user-accounts icon indicating copy to clipboard operation
django-user-accounts copied to clipboard

Delete Account fails

Open reillychase opened this issue 6 years ago • 2 comments

Issue Summary

While logged in, trying to delete account results in a django error page.

Debug

Account delete error:

xpire_date" > '2018-03-30T16:09:31.292697+00:00'::timestamptz AND "django_session"."session_key" = '2iovj0911oh06d2inilmtyj6ug17a42e'); args=(datetime.datetime(2018, 3, 30, 16, 9, 31, 292697, tzinfo=<UTC>), '2iovj0911oh06d2inilmtyj6ug17a42e')
(0.001) SELECT "auth_user"."id", "auth_user"."password", "auth_user"."last_login", "auth_user"."is_superuser", "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."date_joined" FROM "auth_user" WHERE "auth_user"."id" = 1; args=(1,)
(0.001) SELECT "account_accountdeletion"."id", "account_accountdeletion"."user_id", "account_accountdeletion"."email", "account_accountdeletion"."date_requested", "account_accountdeletion"."date_expunged" FROM "account_accountdeletion" WHERE "account_accountdeletion"."user_id" = 1; args=(1,)
(0.001) UPDATE "account_accountdeletion" SET "user_id" = 1, "email" = '[email protected]', "date_requested" = '2018-03-30T15:33:24.601082+00:00'::timestamptz, "date_expunged" = NULL WHERE "account_accountdeletion"."id" = 1; args=(1, '[email protected]', datetime.datetime(2018, 3, 30, 15, 33, 24, 601082, tzinfo=<UTC>), 1)
Internal Server Error: /account/delete/
Traceback (most recent call last):
  File "/home/rchase/hostifinetenv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 35, in inner
    response = get_response(request)
  File "/home/rchase/hostifinetenv/lib/python3.6/site-packages/django/core/handlers/base.py", line 128, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/rchase/hostifinetenv/lib/python3.6/site-packages/django/core/handlers/base.py", line 126, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/rchase/hostifinetenv/lib/python3.6/site-packages/django/views/generic/base.py", line 69, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/rchase/hostifinetenv/lib/python3.6/site-packages/django/utils/decorators.py", line 62, in _wrapper
    return bound_func(*args, **kwargs)
  File "/home/rchase/hostifinetenv/lib/python3.6/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/home/rchase/hostifinetenv/lib/python3.6/site-packages/django/utils/decorators.py", line 58, in bound_func
    return func.__get__(self, type(self))(*args2, **kwargs2)
  File "/home/rchase/hostifinetenv/lib/python3.6/site-packages/account/views.py", line 421, in dispatch
    return super(LogoutView, self).dispatch(*args, **kwargs)
  File "/home/rchase/hostifinetenv/lib/python3.6/site-packages/django/views/generic/base.py", line 89, in dispatch
    return handler(request, *args, **kwargs)
  File "/home/rchase/hostifinetenv/lib/python3.6/site-packages/account/views.py", line 805, in post
    AccountDeletion.mark(self.request.user)
  File "/home/rchase/hostifinetenv/lib/python3.6/site-packages/account/models.py", line 391, in mark
    settings.ACCOUNT_DELETION_MARK_CALLBACK(account_deletion)
  File "/home/rchase/hostifinetenv/lib/python3.6/site-packages/django/conf/__init__.py", line 57, in __getattr__
    val = getattr(self._wrapped, name)
AttributeError: 'Settings' object has no attribute 'ACCOUNT_DELETION_MARK_CALLBACK'

reillychase avatar Mar 30 '18 20:03 reillychase

Looks like I've identified (but not fixed) the account delete problem, it is referenced here: http://blog.pinaxproject.com/2016/10/20/2-0-0-release-django-user-accounts-has-landed/

"This change brings the previously defined functions in the callbacks.py module into line with the hooksets convention we’ve been using for awhile now. It does mean that if you have functions defined in your site for the following settings: ACCOUNT_DELETION_MARK_CALLBACK or ACCOUNT_DELETION_EXPUNGE_CALLBACK you will need to migrate those functions to a hookset implementation if you don’t already have one to add to."

Still not sure what the solution is though or why this isn't working. I'm on latest Django and latest Pinax-stripe

reillychase avatar Mar 30 '18 20:03 reillychase

ACCOUNT_DELETION_MARK_CALLBACK was removed from settings in this commit: https://github.com/pinax/django-user-accounts/commit/526bcda633448e6801a95bdd33d7e0d5eaad0406, but the latest models.py references settings.ACCOUNT_DELETION_MARK_CALLBACK https://github.com/pinax/django-user-accounts/blob/master/account/models.py#L389

Seems like a straightforward bug.

A good PR for this requires:

  • change models.py AccountDeletion to invoke hookset.account_delete_mark and hookset.account_delete_expunge with from account.hooks import hookset.
  • Invoke AccountDeletion.mark and AccountDeletion.expunge methods with test code proving expected results. Post to DeleteView to test mark. Invoke AccountDeletion.expunge class method directly.
  • update documentation for same (remove ACCOUNT_DELETION_*_CALLBACK settings entries, add to ACCOUNT_HOOKSET methods)

grahamu avatar Mar 30 '18 20:03 grahamu