Skip to content

Conversation

@openprojects
Copy link
Contributor

@openprojects openprojects commented Feb 18, 2025

As previously discussed with Alejandro:

we would like to introduce a signal in Indico core that allows refusing sign ups and logins and display a custom message that explains the reason.
This signal will return a tuple: True/False , String. --> The first value explain if the login/signin process can continue or not, the second value contains the eventual error message.

@openprojects openprojects force-pushed the Add-signals-to-prevent-signin-login-for-specific-domains branch from 268efa4 to 3c54ff8 Compare February 18, 2025 09:45
@ThiefMaster
Copy link
Member

As previously discussed with Alejandro.

can you please add details to the PR itself? it's not very convenient for anyone (neither me who would first need to check what discussions we had, nor other devs who are not on our matrix channel) to have any details explaining why a PR is useful only in some other place

@openprojects openprojects force-pushed the Add-signals-to-prevent-signin-login-for-specific-domains branch from 25e164c to fb0b7e9 Compare February 18, 2025 10:19
@ThiefMaster ThiefMaster force-pushed the Add-signals-to-prevent-signin-login-for-specific-domains branch from 21c7843 to c216b3e Compare February 28, 2025 14:26
@ThiefMaster
Copy link
Member

ThiefMaster commented Feb 28, 2025

I made some changes to the signals to make them (in my opinion) more useful, and fixed incorrect documentation.

Please have a look and see if they still do everything you need. This is what I used for testing:

    def init(self):
        super().init()
        self.connect(signals.users.check_signup_email, self._check_signup_email)
        self.connect(signals.users.check_login_data, self._check_login_data)

    def _check_signup_email(self, email, **kwargs):
        print(email, kwargs)
        if email.endswith('@evil.com'):
            return 'YOU SHALL DO NO EVIL'

    def _check_login_data(self, sender, provider, data, **kwargs):
        print(sender, provider, data, kwargs)  # data includes the password as well
        if data['identifier'] == 'moo':
            return 'no cows allowed'

@ThiefMaster ThiefMaster added this to the v3.3 milestone Feb 28, 2025
openprojects and others added 6 commits February 28, 2025 16:36
- clarify when it gets called
- just return strings instead of an allowed flag (this is useless here
  because returning True would not do anything useful)
@ThiefMaster ThiefMaster force-pushed the Add-signals-to-prevent-signin-login-for-specific-domains branch from 8f60f18 to 718c4f7 Compare February 28, 2025 15:36
@ThiefMaster ThiefMaster enabled auto-merge (squash) February 28, 2025 15:36
@openprojects
Copy link
Contributor Author

I made some changes to the signals to make them (in my opinion) more useful, and fixed incorrect documentation.

Please have a look and see if they still do everything you need. This is what I used for testing:

    def init(self):
        super().init()
        self.connect(signals.users.check_signup_email, self._check_signup_email)
        self.connect(signals.users.check_login_data, self._check_login_data)

    def _check_signup_email(self, email, **kwargs):
        print(email, kwargs)
        if email.endswith('@evil.com'):
            return 'YOU SHALL DO NO EVIL'

    def _check_login_data(self, sender, provider, data, **kwargs):
        print(sender, provider, data, kwargs)  # data includes the password as well
        if data['identifier'] == 'moo':
            return 'no cows allowed'

TESTED, works for us, thank you.

@ThiefMaster ThiefMaster merged commit f5ea371 into indico:master Feb 28, 2025
10 checks passed
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.

2 participants