Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use config file in the custom namespace #108

Merged
merged 3 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions docs/add_other_oauth.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,28 +205,31 @@ declare(strict_types=1);

namespace App\Libraries\ShieldOAuth;

use CodeIgniter\HTTP\CURLRequest;
use Config\Services;
use Datamweb\ShieldOAuth\Config\ShieldOAuthConfig;
use Datamweb\ShieldOAuth\Libraries\Basic\AbstractOAuth;
use Exception;

class YahooOAuth extends AbstractOAuth
{
// https://developer.yahoo.com/oauth2/guide/flows_authcode/#refresh-token-label
static private $API_CODE_URL = 'https://api.login.yahoo.com/oauth2/request_auth';
static private $API_TOKEN_URL = 'https://api.login.yahoo.com/oauth2/get_token';
static private $API_USER_INFO_URL = 'https://api.login.yahoo.com/openid/v1/userinfo';
static private $APPLICATION_NAME = 'ShieldOAuth';
private static string $API_CODE_URL = 'https://api.login.yahoo.com/oauth2/request_auth';
private static string $API_TOKEN_URL = 'https://api.login.yahoo.com/oauth2/get_token';
private static string $API_USER_INFO_URL = 'https://api.login.yahoo.com/openid/v1/userinfo';
private static string $APPLICATION_NAME = 'ShieldOAuth';

protected string $token;
protected $client;
protected $config;
protected CURLRequest $client;
protected ShieldOAuthConfig $config;
protected string $client_id;
protected string $client_secret;
protected string $callback_url;

public function __construct(string $token = '')
{
$this->token = $token;
$this->client = \Config\Services::curlrequest();
$this->client = Services::curlrequest();

$this->config = config('ShieldOAuthConfig');
$this->callback_url = base_url('oauth/' . $this->config->call_back_route);
Expand Down
2 changes: 1 addition & 1 deletion src/Database/Migrations/2022-10-20-182737_ShieldOAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct()
parent::__construct();

/** @var ShieldOAuthConfig $config */
$config = config(ShieldOAuthConfig::class);
$config = config('ShieldOAuthConfig');
$this->first_name = $config->usersColumnsName['first_name'];
$this->last_name = $config->usersColumnsName['last_name'];
$this->avatar = $config->usersColumnsName['avatar'];
Expand Down
3 changes: 2 additions & 1 deletion src/Libraries/GithubOAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use CodeIgniter\HTTP\CURLRequest;
use Config\Services;
use Datamweb\ShieldOAuth\Config\ShieldOAuthConfig;
use Datamweb\ShieldOAuth\Libraries\Basic\AbstractOAuth;
use Exception;

Expand All @@ -26,7 +27,7 @@ class GithubOAuth extends AbstractOAuth
private static string $APPLICATION_NAME = 'ShieldOAuth';
protected string $token;
protected CURLRequest $client;
protected ?object $config = null;
protected ShieldOAuthConfig $config;
protected string $client_id;
protected string $client_secret;
protected string $callback_url;
Expand Down
3 changes: 2 additions & 1 deletion src/Libraries/GoogleOAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use CodeIgniter\HTTP\CURLRequest;
use Config\Services;
use Datamweb\ShieldOAuth\Config\ShieldOAuthConfig;
use Datamweb\ShieldOAuth\Libraries\Basic\AbstractOAuth;
use Exception;

Expand All @@ -26,7 +27,7 @@ class GoogleOAuth extends AbstractOAuth
private static string $APPLICATION_NAME = 'ShieldOAuth';
protected string $token;
protected CURLRequest $client;
protected ?object $config = null;
protected ShieldOAuthConfig $config;
protected string $client_id;
protected string $client_secret;
protected string $callback_url;
Expand Down
2 changes: 1 addition & 1 deletion src/Models/ShieldOAuthModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected function initialize(): void
parent::initialize();

/** @var ShieldOAuthConfig $config */
$config = config(ShieldOAuthConfig::class);
$config = config('ShieldOAuthConfig');

// Merge properties with parent
$this->allowedFields = array_merge($this->allowedFields, [
Expand Down
Loading