mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-13 06:32:40 +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:
commit
73557bdc59
@ -286,11 +286,25 @@ class LoginController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($user) {
|
if ($user) {
|
||||||
|
|
||||||
$client = new Google_Client();
|
$client = new Google_Client();
|
||||||
$client->setClientId(config('ninja.auth.google.client_id'));
|
$client->setClientId(config('ninja.auth.google.client_id'));
|
||||||
$client->setClientSecret(config('ninja.auth.google.client_secret'));
|
$client->setClientSecret(config('ninja.auth.google.client_secret'));
|
||||||
$client->setRedirectUri(config('ninja.app_url'));
|
$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 = '';
|
$refresh_token = '';
|
||||||
|
|
||||||
|
@ -35,19 +35,19 @@ class RangeDetectionTest extends TestCase
|
|||||||
|
|
||||||
foreach($ranges as $range)
|
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)
|
private function makeRanges(array $range)
|
||||||
{
|
{
|
||||||
|
|
||||||
return range($range[0], $range[1]);
|
return range($range[0], $range[1]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user