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

Email Case Sensitivity #92

Open
gbourda opened this issue May 14, 2024 · 1 comment
Open

Email Case Sensitivity #92

gbourda opened this issue May 14, 2024 · 1 comment

Comments

@gbourda
Copy link

gbourda commented May 14, 2024

Hi, I'm using laravel-saml2 and encountering a case-sensitive email issue where the email returned by the Identity Provider does not match the case of the email stored in our database, causing login failures. Is there a way to configure the package to handle email case insensitivity or any suggestions to fix this? Thanks!

@skydudie
Copy link

skydudie commented Jun 11, 2024

You can achieve this by changing the case of the email address returned by the IDP when you handle the SignedIn event.

Within the listener that subscribed to the SignedIn event, you can change the case of the email address before retrieving the user from the database. For example:

public function handle(SignedIn $event)
    {
        // Get the returned user from the IDP
        $samlUser = $event->getSaml2User();

        // Convert to lowercase
        $email = strtolower($samlUser->getUserId());

        // Get user from DB
        $user = User::where('email', $email)->first();

        // Log the user in
        Auth::login($user);
    }

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

No branches or pull requests

2 participants