Projet

Général

Profil

0002-create-authentic2.utils-package-35302.patch

Benjamin Dauvergne, 09 août 2019 14:39

Télécharger (3,97 ko)

Voir les différences:

Subject: [PATCH 2/4] create authentic2.utils package (#35302)

 src/authentic2/{utils.py => utils/__init__.py} | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
 rename src/authentic2/{utils.py => utils/__init__.py} (99%)
src/authentic2/utils.py → src/authentic2/utils/__init__.py
65 65
from authentic2.saml.saml2utils import filter_attribute_private_key, \
66 66
    filter_element_private_key
67 67

  
68
from . import plugins, app_settings, constants, crypto
68
from .. import plugins, app_settings, constants, crypto
69 69

  
70 70

  
71 71
class CleanLogMessage(logging.Filter):
......
368 368
def record_authentication_event(request, how, nonce=None):
369 369
    '''Record an authentication event in the session and in the database, in
370 370
       later version the database persistence can be removed'''
371
    from . import models
371
    from .. import models
372 372
    logging.getLogger(__name__).info('logged in (%s)', how)
373 373
    authentication_events = request.session.setdefault(constants.AUTHENTICATION_EVENTS_SESSION_KEY,
374 374
                                                       [])
......
414 414
def login(request, user, how, service_slug=None, nonce=None, **kwargs):
415 415
    '''Login a user model, record the authentication event and redirect to next
416 416
       URL or settings.LOGIN_REDIRECT_URL.'''
417
    from . import hooks
417
    from .. import hooks
418 418

  
419 419
    last_login = user.last_login
420 420
    auth_login(request, user)
......
607 607
       - <template_name>_body.txt for the plain text body
608 608
       - <template_name>_body.html for the HTML body
609 609
    '''
610
    from . import middleware
610
    from .. import middleware
611 611
    if isinstance(template_names, six.string_types):
612 612
        template_names = [template_names]
613 613
    if hasattr(user_or_email, 'email'):
......
736 736

  
737 737
def build_reset_password_url(user, request=None, next_url=None, set_random_password=True, sign_next_url=True):
738 738
    '''Build a reset password URL'''
739
    from .compat import default_token_generator
739
    from ..compat import default_token_generator
740 740

  
741 741
    if set_random_password:
742 742
        user.set_password(uuid.uuid4().hex)
......
762 762
                             set_random_password=True,
763 763
                             sign_next_url=True,
764 764
                             **kwargs):
765
    from . import middleware
765
    from .. import middleware
766 766

  
767 767
    if not user.email:
768 768
        raise ValueError('user must have an email')
......
877 877

  
878 878
def good_next_url(request, next_url):
879 879
    '''Check if an URL is a good next_url'''
880
    from . import hooks
880
    from .. import hooks
881 881

  
882 882
    if not next_url:
883 883
        return False
......
1090 1090

  
1091 1091
def get_user_flag(user, name, default=None):
1092 1092
    '''Get a boolean flag settable at user, by a hook, globally or ou wide'''
1093
    from . import hooks
1093
    from .. import hooks
1094 1094

  
1095 1095
    setting_value = getattr(app_settings, 'A2_USER_' + name.upper(), None)
1096 1096
    if setting_value is not None:
......
1112 1112

  
1113 1113

  
1114 1114
def user_can_change_password(user=None, request=None):
1115
    from . import hooks
1115
    from .. import hooks
1116 1116
    if not app_settings.A2_REGISTRATION_CAN_CHANGE_PASSWORD:
1117 1117
        return False
1118 1118
    if request is not None and user is None and hasattr(request, 'user'):
1119
-