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

Sorry, that username already exists! Error after first login attempt #64

Open
rfair404 opened this issue Jun 26, 2020 · 3 comments
Open

Comments

@rfair404
Copy link

I have installed the plugin and coordinated the metadata with my SAML provider. Everything seems to be working as expected, however when I attempt to log in for a second time I get an error: Sorry, that username already exists!

Any idea how this can be resolved?

@tlaverdure
Copy link

I'm experiencing the same issue on a multi site instance. Users were able to sign in and then on a second attempt Sorry, that username already exists! continues to show up.

@tlaverdure
Copy link

Looks like on my end it was an issue with a username being used as the NameID while not being an actual email address.

$is_email_auth = 'emailAddress' === substr( $saml->getNameIdFormat(), - strlen( 'emailAddress' ) );
if ( $is_email_auth ) {
$email = filter_var( $saml->getNameId(), FILTER_VALIDATE_EMAIL );
} else {
$email_field = $map['user_email'];
$email = current( (array) $saml->getAttribute( $email_field ) );
}

@ecitydevelopers
Copy link

ecitydevelopers commented Jan 22, 2021

We had this issue as well because our current site was not using email address for the user logins. so i changed the logic to be

	if ( $is_email_auth ) {
		$email = filter_var( $saml->getNameId(), FILTER_VALIDATE_EMAIL );
	} else {
		$email_field = $map['user_email'];
		$email       = current( (array) $saml->getAttribute( $email_field ) );
	}

	if(!$email)
	{
		//fix for not being able to find the email address
		$email = isset( $map['user_email'], $attributes[ $map['user_email'] ] ) && is_array( $attributes[ $map['user_email'] ] ) ? reset( $attributes[ $map['user_email'] ] ) : '';
	}

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

3 participants