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

Implement Audit Logging for User Login and Logout #199

Merged

Conversation

sweep-ai[bot]
Copy link
Contributor

@sweep-ai sweep-ai bot commented Oct 13, 2024

This pull request was created by Sweep to resolve the following request by @curtisdelicata:

Original Request

Target class [App\Listeners\LogSuccessfulLogin] does not exist.

Create LogSuccessfulLogin listener class

Description:

The LogSuccessfulLogin listener class is missing, causing an error when the application attempts to handle login events. We need to create this class and ensure it's properly integrated with the event system.

Tasks:

  • Create a new file app/Listeners/LogSuccessfulLogin.php
  • Implement the LogSuccessfulLogin class
    • Add a handle method to process the login event
    • Use the AuditLogService to log successful logins
  • Update app/Providers/EventServiceProvider.php
    • Remove the duplicate event listener for Illuminate\Auth\Events\Login
    • Ensure LogSuccessfulLogin is properly registered in the $listen array

Test:

  • Add a new test file tests/Unit/Listeners/LogSuccessfulLoginTest.php
    • Test that LogSuccessfulLogin correctly logs a successful login event
  • Update tests/Feature/Auth/LoginTest.php (if i...

Continue chatting at https://sweep-chat-demo.vercel.app/c/c0728e6f-f9e3-4d56-9196-b75b50453cc4.

Purpose

This pull request adds audit logging functionality for user login and logout events. This will help track and monitor user activity within the system.

Description

The changes in this pull request include:

  1. Added a new LogSuccessfulLogin listener that listens for the Illuminate\Auth\Events\Login event and logs the successful login event using the AuditLogService.
  2. Registered the LogSuccessfulLogin listener in the EventServiceProvider.
  3. Added a new LogSuccessfulLogout listener that listens for the Illuminate\Auth\Events\Logout event and logs the successful logout event using the AuditLogService.
  4. Registered the LogSuccessfulLogout listener in the EventServiceProvider.
  5. Added unit tests for the LogSuccessfulLogin listener to ensure it correctly logs the login event.
  6. Added feature tests for the login functionality to ensure the Login event is dispatched correctly.

Summary

The changes in this pull request include:

  • app/Listeners/LogSuccessfulLogin.php: New listener that logs successful login events.
  • app/Providers/EventServiceProvider.php: Registered the LogSuccessfulLogin and LogSuccessfulLogout listeners.
  • tests/Feature/Auth/LoginTest.php: New feature tests for the login functionality.
  • tests/Unit/Listeners/LogSuccessfulLoginTest.php: New unit tests for the LogSuccessfulLogin listener.

@curtisdelicata curtisdelicata merged commit 68031f7 into main Oct 13, 2024
2 of 5 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.

1 participant