Browse Source

Routes

tags/1.0
Maxime Renou 2 years ago
parent
commit
fedd615ed5
  1. 8
      config/bconnect.php
  2. 17
      src/Connect.php
  3. 25
      src/Controllers/ConnectController.php
  4. 4
      src/Facades/Connect.php

8
config/bconnect.php

@ -10,12 +10,12 @@ return [
/**
* Route that redirects to Bluesquare Connect
*/
'login_url' => '/oauth/authorize',
'login_url' => '/connect/authorize',
/**
* OAuth callback URL
*/
'redirect_url' => env('BCONNECT_REDIRECT', 'http://localhost:8000/oauth/callback'),
'redirect_url' => env('BCONNECT_REDIRECT', 'http://localhost:8000/connect/callback'),
/**
* OAuth client id
@ -30,8 +30,8 @@ return [
/**
* OAuth scopes (separated with commas)
*/
'user_scopes' => '*',
'client_scopes' => '*',
'user_scopes' => env('BCONNECT_USER_SCOPES', '*'),
'client_scopes' => env('BCONNECT_CLIENT_SCOPES', '*'),
/**
* Bluesquare Connect URL

17
src/Connect.php

@ -7,6 +7,7 @@ use GuzzleHttp\Client;
use Illuminate\Http\Request;
use Illuminate\Routing\Router;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Str;
use Psr\Http\Message\StreamInterface;
@ -361,8 +362,20 @@ class Connect
return config('bconnect.url') ?? 'https://connect.bluesquare.io';
}
public function routes(Router $router)
public function routes()
{
dump($router);
Route::middleware('web')
->namespace('Bluesquare\Connect\Controllers')
->group(function () {
Route::get('connect/authorize', 'ConnectController@authorize');
Route::get('connect/callback', 'ConnectController@callback');
});
Route::prefix('api')
->middleware('api')
->namespace('Bluesquare\Connect\Controllers')
->group(function () {
Route::post('connect/webhook', 'ConnectController@webhook');
});
}
}

25
src/Controllers/ConnectController.php

@ -0,0 +1,25 @@
<?php
namespace Bluesquare\Connect\Controllers;
use Bluesquare\Connect\Connect;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
class ConnectController extends Controller
{
public function authorize(Connect $connect)
{
return $connect->redirect();
}
public function callback(Request $request, Connect $connect)
{
return $connect->loginFromCallback($request);
}
public function webhook(Request $request, Connect $connect)
{
return $connect->handleWebhook($request);
}
}

4
src/Facades/Connect.php

@ -12,8 +12,6 @@ class Connect extends Facade
*/
public static function routes()
{
static::$app->make(\Bluesquare\Connect\Connect::class)->routes(
static::$app->make('router')
);
static::$app->make(\Bluesquare\Connect\Connect::class)->routes();
}
}

Loading…
Cancel
Save