Skip to content

Commit

Permalink
Some GitHub users dont have there email exposed.
Browse files Browse the repository at this point in the history
In this case use username and username+example.com
  • Loading branch information
MarcHagen committed Feb 12, 2024
1 parent 82c0d28 commit 03eb7fc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Integrations/Github/GitHubIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ public function fetchUser(Request|array $requestOrToken, array $options = [], ar
$response = $response->toArray();

$response['user_name'] = $response['login'] ?? null;
$response['user_identifier'] = $response['email'];
$response['user_identifier'] = $response['email'] ?? $response['login'];
$response['external_id'] = isset($response['id']) ? $this->getConfig()->getName() . ':' . $response['id'] : null;

return $response;
Expand Down Expand Up @@ -520,10 +520,12 @@ protected function getApiHeaders(array $token, array $default = []): array
*/
public function createUser(array $userData): User
{
$email = $userData['email'] ?? (str_contains($userData['user_identifier'], '@') ? $userData['user_identifier'] : $userData['user_identifier'] .'@example.com');

$user = new User();
$user->setEnabled(true)
->setRoles($this->getConfig()->roles())
->setEmail($userData['email'])
->setEmail($email)
->setUsername($userData['login'])
->setGithubId($userData['external_id'] ?? null)
->generateApiToken();
Expand Down

0 comments on commit 03eb7fc

Please sign in to comment.