laravel-saml2
laravel-saml2 copied to clipboard
Email Case Sensitivity
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!
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);
}