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

Save Previous Panel URL for after Login #34

Merged
merged 20 commits into from Dec 7, 2023
Merged

Conversation

chrisreedio
Copy link
Owner

@chrisreedio chrisreedio commented Nov 16, 2023

This is WIP but was originally intended for sending the user back to the panel of the login page they used.

chrisreedio and others added 8 commits November 9, 2023 19:53
Refactored SocialmentPlugin to support multi-panel functionality, and added new routes for handling panel-based redirects. Improved error handling in SocialmentController's callback method. Updated providers-list view to support dynamic provider URLs based on panel configuration.
This commit modifies the redirect after a successful login to direct the user to their intended URL. This is achieved by pulling the intended URL from the session, falling back to the home route if not found.
…ation

A new `redirectSpa` method has been added to the SocialmentController, which stores the referring URL in the session and initiates a socialite redirect. The callback method now also supports intended URL redirection and has been configured to consider 'spa' as the authentication guard. This change will allow the application to handle Single Page Application (SPA) authentication flows more elegantly.

Additional changes include updates to the routes configuration to incorporate the new `redirectSpa` method, and modifications to the `providers-list.blade.php` view to reflect the updated routing.

Updated `socialment.php` configuration file to include a new `spa` array containing the home URL for SPAs, making it easily customizable. This will ensure that users are redirected to the correct location after a successful login in an SPA context.

This enhancement will improve the application's flexibility in handling different authentication scenarios and improve the user experience for SPA-based log
The user model reference in the socialment configuration file has been
updated to use a string representation instead of directly referring to the
class.
@chrisreedio
Copy link
Owner Author

This has expanded to include Social SPA authentication as well.
More documentation to follow.

chrisreedio and others added 10 commits December 5, 2023 19:31
Reformatted README to enhance readability and maintain line width consistency. Expanded documentation to include new SPA authentication feature, detailing setup, middleware configuration, and necessary environment variable adjustments. The new SPA guard setup is especially significant for developers integrating front-end SPAs with backend Laravel applications, offering a more streamlined authentication process between the two systems. The changes also include a warning about the experimental nature of the SPA feature, advising developers to use it cautiously.

Added a new file `SpaAuthentication.php` to handle SPA authentication middleware logic, enforcing user authentication for designated SPA routes and providing a more secure user experience for SPA applications.

Note: While the feature is still in development, the documentation outlines the current setup process and acknowledges the potential for future changes.
Import Closure class to ensure proper type hinting and function resolution within the middleware
Refactor `SpaAuthentication` middleware to accept a guard parameter.
This change simplifies auth checks, allowing dynamic guard assignment.
Removed redundant comments and outdated response handling.
Improved API error response for unauthenticated access in SPA context.
- Moved SocialmentController to Http namespace
- Added handling for SPA authentication
- Created new UserResponse and SpaAuthController
- Implemented CSRF cookie for SPA login
- Refactored SocialmentPlugin to support global pre/post login callbacks
- Added new routes for SPA authentication
- Simplified OAuth callback logic in SocialmentController

This change streamlines the social authentication process by organizing controllers, adding SPA-specific endpoints, and allowing global hooks for pre and post login actions. It enhances the security and structure of the codebase, making it more maintainable and easier to understand.
- Deprecate old redirect method in favor of centralized one
- Ensure intended URL is stored before redirecting to OAuth provider
- Redirect directly to intended URL after login instead of route
- Clean up unnecessary code and comments for clarity and maintainability

By centralizing the redirect logic and handling of intended URLs, this commit aims to reduce complexity and potential for bugs in the social authentication flow. It simplifies the callback method by removing fallbacks that are no longer necessary and ensures users are redirected to their intended URL immediately after login, improving the user experience. 🚀
@chrisreedio chrisreedio self-assigned this Dec 7, 2023
@chrisreedio chrisreedio marked this pull request as ready for review December 7, 2023 11:32
@chrisreedio chrisreedio merged commit bfa7877 into 3.x Dec 7, 2023
11 checks passed
@chrisreedio chrisreedio deleted the save-previous-url branch December 7, 2023 11:33
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.

None yet

1 participant