Skip to content
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

Pass the User instance to hook methods #164

Closed
wants to merge 1 commit into from

Conversation

tchaumeny
Copy link

This is related to issue #163

With this new signature, we can implement hooks to check user may log in using SAML for instance:

def before_login_hook(user_identity, target_user):
    """Check user SAML flag"""
    if not target_user.saml_login_enabled:
        raise PermissionDenied("User cannot login")
 
 def create_user_hook(user_identity, target_user):
     """Automatically allow login for user created through SAML"""
     target_user.saml_login_enabled = True
     target_user.save()

Note: this should be mentioned in changelog, as it requires updating the signature of the hooks methods.

@tchaumeny tchaumeny changed the title Pass the user object to hooks methods — See #163 Pass the User object to hooks methods Jun 28, 2021
@tchaumeny tchaumeny changed the title Pass the User object to hooks methods Pass the User instance to hooks methods Jun 28, 2021
@tchaumeny tchaumeny changed the title Pass the User instance to hooks methods Pass the User instance to hook methods Jul 5, 2021
@tchaumeny tchaumeny closed this Mar 23, 2022
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

Successfully merging this pull request may close these issues.

1 participant