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

Add Logout Callback Functionality #39

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Zingzy
Copy link

@Zingzy Zingzy commented Oct 5, 2024

Overview

This PR introduces the ability to register and execute callback functions upon user logout in the SimpleLogin class. This enhancement allows users to perform custom actions, such as logging events or clearing additional session data, immediately after a user logs out.

Changes

  • Modified logout Method:

    • The logout method now iterates over a list of registered callbacks and executes each one after clearing the session and flashing the logout message.
  • New Method register_on_logout_callback:

    • Added a new method register_on_logout_callback to allow users to register their custom callback functions.
  • Updated Tests:

    • Enhanced the existing logout test to verify that the registered callbacks are executed upon logout.

Code Example

Here's how users can register their custom callbacks:

def my_post_logout_callback():
    print("User has logged out")

def another_post_logout_callback():
    print("Another action after logout")

app = Flask(__name__)
simple_login = SimpleLogin(app)
simple_login.register_on_logout_callback(my_post_logout_callback)
simple_login.register_on_logout_callback(another_post_logout_callback)

Testing

  • Manual Testing:

    • Verified the functionality by running a local Flask application and observing the console output upon logout.
  • Automated Testing:

    • Updated the test suite to include checks for the new callback functionality.
    • Ran the tests using pytest to ensure all tests pass successfully.

Additional Notes

  • Users can register multiple callbacks, and they will be executed in the order they were registered.

This PR addresses issue #36

@Zingzy
Copy link
Author

Zingzy commented Oct 8, 2024

Hello @cuducos please review this pr 😄

@cuducos
Copy link
Member

cuducos commented Oct 8, 2024

Thank you for the great PR description! I appreciate the effort you put into it.

I kindly ask that you refrain from commenting for reviews, as it adds unnecessary noise to my inbox. I have a full-time job and a personal life, along with my involvement in this and other open-source projects. Please rest assured that I will review your code as soon as possible, but I do have other priorities now. Thank you for your understanding 💜

@Zingzy
Copy link
Author

Zingzy commented Oct 8, 2024

Thank you for the great PR description! I appreciate the effort you put into it.

I kindly ask that you refrain from commenting for reviews, as it adds unnecessary noise to my inbox. I have a full-time job and a personal life, along with my involvement in this and other open-source projects. Please rest assured that I will review your code as soon as possible, but I do have other priorities now. Thank you for your understanding 💜

Hey, I am really sorry, I do understand... Please take your time to review this PR 😀

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