Skip to content

Commit

Permalink
change to vatger connect
Browse files Browse the repository at this point in the history
  • Loading branch information
paulhollmann committed Jun 22, 2024
1 parent db51d3a commit 55b0a1b
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 4 deletions.
6 changes: 3 additions & 3 deletions app/Access/Controllers/ConnectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace BookStack\Access\Controllers;

use BookStack\App\Providers\VatgerConnectProvider;
use BookStack\App\Providers\VatsimConnectProvider;
use BookStack\Http\Controller;
use BookStack\Users\Models\User;
Expand All @@ -10,7 +11,6 @@
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Str;
use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
use UnexpectedValueException;
Expand All @@ -20,14 +20,14 @@ class ConnectController extends Controller
/**
* The Authentication Provider Instance
*/
protected VatsimConnectProvider $provider;
protected VatgerConnectProvider $provider;

/**
* Initialize the Controller with a new ConnectProvider instance
*/
public function __construct()
{
$this->provider = new VatsimConnectProvider();
$this->provider = new VatgerConnectProvider();
}

/**
Expand Down
43 changes: 43 additions & 0 deletions app/App/Providers/VatgerConnectProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace BookStack\App\Providers;

use League\OAuth2\Client\Provider\GenericProvider;
use Illuminate\Support\Str;
use League\OAuth2\Client\Token\AccessToken;

class VatgerConnectProvider extends GenericProvider
{
/**
* Initialize the Provider from configuration
*/
public function __construct()
{
parent::__construct([
'clientId' => config('connect.id'),
'clientSecret' => config('connect.secret'),
'redirectUri' => route('authentication.connect.login'),
'urlAuthorize' => config('connect.endpoints.authorize'),
'urlAccessToken' => config('connect.endpoints.token'),
'urlResourceOwnerDetails' => config('connect.endpoints.user'),
'scopes' => (Str::contains(config('connect.scopes'), ',')) ? str_replace(',', ' ', config('connect.scopes'),) : config('connect.scopes'),
'scopeSeparator' => ' '
]);
}

public function getMappedData(AccessToken $accessToken): array
{
$resourceOwner = json_decode(json_encode($this->getResourceOwner($accessToken)->toArray()));
$token_valid = $resourceOwner?->data?->oauth?->token_valid;
return [
'id' => $resourceOwner?->id,
'firstname' => $resourceOwner?->firstname,
'lastname' => $resourceOwner?->lastname,
'email' => $resourceOwner?->email,
'token_valid' => $token_valid,
'access_token' => $token_valid ? $accessToken->getToken() : null,
'refresh_token' => $token_valid ? $accessToken->getRefreshToken() : null,
'token_expires' => $token_valid ? $accessToken->getExpires() : null,
];
}
}
2 changes: 1 addition & 1 deletion resources/views/users/account/profile.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ class="setting-list-label">{{ trans('settings.users_avatar') }}</label>
'name' => 'profile_image',
'imageClass' => 'avatar large'
])
--}}
</div>
--}}
</div>

@include('users.parts.language-option-row', ['value' => old('language') ?? user()->getLocale()->appLocale()])
Expand Down

0 comments on commit 55b0a1b

Please sign in to comment.