1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-11 05:32:39 +01:00

Merge pull request #5007 from turbo124/v5-develop

Catch if an OAuth user doesn't exist and attempts to login
This commit is contained in:
David Bomba 2021-02-28 20:59:14 +11:00 committed by GitHub
commit 73557bdc59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 7 deletions

View File

@ -286,11 +286,25 @@ class LoginController extends BaseController
}
if ($user) {
$client = new Google_Client();
$client->setClientId(config('ninja.auth.google.client_id'));
$client->setClientSecret(config('ninja.auth.google.client_secret'));
$client->setRedirectUri(config('ninja.app_url'));
$token = $client->authenticate(request()->input('server_auth_code'));
$token = false;
try{
$token = $client->authenticate(request()->input('server_auth_code'));
}
catch(\Exception $e) {
return response()
->json(['message' => ctrans('texts.invalid_credentials')], 401)
->header('X-App-Version', config('ninja.app_version'))
->header('X-Api-Version', config('ninja.minimum_client_version'));
}
$refresh_token = '';

View File

@ -35,19 +35,19 @@ class RangeDetectionTest extends TestCase
foreach($ranges as $range)
{
$expanded_ranges[] = $this->makeRanges($range);
$expanded_ranges = array_merge(array_values($expanded_ranges),array_values($this->makeRanges($range)));
}
foreach($ranges as $range)
{
}
$value_count_array = array_count_values($expanded_ranges);
$value_count_array = array_diff($value_count_array, [1]);
$this->assertEquals(count($value_count_array), 1);
}
private function makeRanges(array $range)
{
return range($range[0], $range[1]);
}