Skip to content

Commit

Permalink
fix connect controller
Browse files Browse the repository at this point in the history
  • Loading branch information
paulhollmann committed Aug 26, 2023
1 parent 5137005 commit 9ff7071
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 22 deletions.
24 changes: 7 additions & 17 deletions app/Access/Controllers/VATSIMConnectController.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
<?php


namespace BookStack\Http\Controllers\Auth;
namespace BookStack\Access\Controllers;

use BookStack\Auth\Role;
use BookStack\Providers\ConnectProvider;
use BookStack\Auth\User;
use BookStack\Http\Controllers\Controller;
use BookStack\Http\Controller;
use BookStack\Users\Models\User;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Str;
use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
use UnexpectedValueException;
Expand All @@ -22,9 +20,8 @@ class VATSIMConnectController extends Controller
{
/**
* The VATSIM Authentication Provider Instance
* @var ConnectProvider
*/
protected $_provider;
protected ConnectProvider $_provider;

/**
* Initialize the Controller with a new ConnectProvider instance
Expand All @@ -37,9 +34,6 @@ function __construct()
/**
* Authentication entrypoint
* This function will handle the state and request of an authentication attempt
*
* @param Request
* @return RedirectResponse|Redirect
*/
public function login(Request $request)
{
Expand Down Expand Up @@ -111,7 +105,7 @@ protected function _verifyLogin(Request $request)
}

if (User::query()->where('email', $resourceOwner->data->personal->email)->exists()) {
//return redirect()->route('vatsim.authentication.connect.failed');
return redirect()->route('vatsim.authentication.connect.failed');
}

// All checks completed. Let's finally sign in the user
Expand Down Expand Up @@ -185,20 +179,16 @@ protected function _completeLogin($resourceOwner, $accessToken)
/**
* Display a failed message and then return to the login
*
* @param Request $request
* @return RedirectResponse
*/
public function failed(Request $request): RedirectResponse
{
return redirect()->route('landing')->withErrors('Error logging in. Please try again.');
return redirect('/')->withErrors('Error logging in. Please try again.');
}

/**
* End an authenticated session
*
* @return Redirect
*/
public function logout()
public function logout(): RedirectResponse
{
Auth::logout();

Expand Down
8 changes: 3 additions & 5 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,11 +333,9 @@

Route::prefix('authentication')->group(function () {
Route::prefix('connect')->group(function () {
Route::get('login', [Auth\VATSIMConnectController::class, 'login'])->name('vatsim.authentication.connect.login');
Route::get('logout', [Auth\VATSIMConnectController::class, 'logout'])->name('vatsim.authentication.connect.logout');
Route::get('failed', function (\BookStack\Http\Request $request) {
return redirect('/');
})->name('vatsim.authentication.connect.failed');
Route::get('login', [AccessControllers\VATSIMConnectController::class, 'login'])->name('vatsim.authentication.connect.login');
Route::get('logout', [AccessControllers\VATSIMConnectController::class, 'logout'])->name('vatsim.authentication.connect.logout');
Route::get('failed', [AccessControllers\VATSIMConnectController::class, 'failed'])->name('vatsim.authentication.connect.failed');
});
});

Expand Down

0 comments on commit 9ff7071

Please sign in to comment.