import hashlib

from django.conf import settings
from django.core.signals import setting_changed
from django.dispatch import receiver

from .backends import UrlAuthBackendMixin


@receiver(setting_changed)
def reset_sesame_settings(**kwargs):
    UABM = UrlAuthBackendMixin

    if kwargs['setting'] == 'SESAME_SALT':
        UABM.salt = getattr(settings, 'SESAME_SALT', 'sesame')
    elif kwargs['setting'] == 'SESAME_DIGEST':
        UABM.digest = getattr(settings, 'SESAME_DIGEST', hashlib.md5)
    elif kwargs['setting'] == 'SESAME_ITERATIONS':
        UABM.iterations = getattr(settings, 'SESAME_ITERATIONS', 10000)

    elif kwargs['setting'] == 'SESAME_MAX_AGE':
        UABM.max_age = getattr(settings, 'SESAME_MAX_AGE', None)
    elif kwargs['setting'] == 'SESAME_ONE_TIME':
        UABM.one_time = getattr(settings, 'SESAME_ONE_TIME', False)
    elif kwargs['setting'] == 'SESAME_INVALIDATE_ON_PASSWORD_CHANGE':
        UABM.invalidate_on_password_change = getattr(
            settings, 'SESAME_INVALIDATE_ON_PASSWORD_CHANGE', True)

@@ -299,357 +299,8 @@
 %5D ==
- 'SESAME_SALT':%0A        UABM.salt = getattr(settings, 'SESAME_SALT', 'sesame')%0A    elif kwargs%5B'setting'%5D == 'SESAME_DIGEST':%0A        UABM.digest = getattr(settings, 'SESAME_DIGEST', hashlib.md5)%0A    elif kwargs%5B'setting'%5D == 'SESAME_ITERATIONS':%0A        UABM.iterations = getattr(settings, 'SESAME_ITERATIONS', 10000)%0A%0A    elif kwargs%5B'setting'%5D ==
  'SE

Remove unused code (YAGNI).