Skip to content

Commit

Permalink
Fix generic OAuth2 connector unable to create username from email #103
Browse files Browse the repository at this point in the history
  • Loading branch information
figureone committed Nov 1, 2021
1 parent 1512231 commit ba7ee58
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/authorizer/class-authentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,11 @@ function ( $entry ) {

// Set the username to the email prefix (if we don't have one).
if ( ! empty( $email ) && empty( $username ) ) {
$username = current( explode( '@', $email ) );
if ( is_array( $email ) && ! empty( $email[0] ) ) {
$username = current( explode( '@', $email[0] ) );
} else {
$username = current( explode( '@', $email ) );
}
}
}

Expand Down Expand Up @@ -581,7 +585,11 @@ function ( $entry ) {

// Set the username to the email prefix (if we don't have one).
if ( ! empty( $email ) && empty( $username ) ) {
$username = current( explode( '@', $email ) );
if ( is_array( $email ) && ! empty( $email[0] ) ) {
$username = current( explode( '@', $email[0] ) );
} else {
$username = current( explode( '@', $email ) );
}
}
}

Expand Down

0 comments on commit ba7ee58

Please sign in to comment.