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: Apply config settings #170

Merged
merged 6 commits into from
Sep 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
136 changes: 68 additions & 68 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,73 +1,73 @@
{
"name": "datamweb/shield-oauth",
"description": "OAuth for CodeIgniter Shield",
"license": "MIT",
"type": "library",
"keywords": [
"codeigniter4",
"shield",
"oauth",
"googleOauth",
"githubOauth",
"authentication",
"authorization"
"name": "datamweb/shield-oauth",
"description": "OAuth for CodeIgniter Shield",
"license": "MIT",
"type": "library",
"keywords": [
"codeigniter4",
"shield",
"oauth",
"googleOauth",
"githubOauth",
"authentication",
"authorization"
],
"authors": [
{
"name": "Pooya Parsa Dadashi",
"email": "[email protected]",
"role": "Developer"
}
],
"homepage": "https://github.com/datamweb/shield-oauth",
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": "^7.4.3 || ^8.0 || ^8.1 || ^8.2",
"ext-curl": "*",
"codeigniter4/shield": "^1.0"
},
"require-dev": {
"codeigniter4/devkit": "^1.0",
"codeigniter4/framework": "^4.3.5",
"codeigniter4/shield": "^1.0",
"rector/rector": "1.2.5"
},
"autoload": {
"psr-4": {
"Datamweb\\ShieldOAuth\\": "src"
},
"exclude-from-classmap": [
"**/Database/Migrations/**"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests",
"Tests\\Support\\": "tests/_support"
}
},
"scripts": {
"post-update-cmd": [
"bash admin/setup.sh"
],
"authors": [
{
"name": "Pooya Parsa Dadashi",
"email": "[email protected]",
"role": "Developer"
}
"ci": [
"Composer\\Config::disableProcessTimeout",
"@cs"
],
"homepage": "https://github.com/datamweb/shield-oauth",
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": "^7.4.3 || ^8.0 || ^8.1 || ^8.2",
"ext-curl": "*",
"codeigniter4/shield": "^1.0"
},
"require-dev": {
"codeigniter4/devkit": "^1.0",
"codeigniter4/framework": "^4.3.5",
"codeigniter4/shield": "^1.0",
"rector/rector": "1.2.5"
},
"autoload": {
"psr-4": {
"Datamweb\\ShieldOAuth\\": "src"
},
"exclude-from-classmap": [
"**/Database/Migrations/**"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests",
"Tests\\Support\\": "tests/_support"
}
},
"scripts": {
"post-update-cmd": [
"bash admin/setup.sh"
],
"ci": [
"Composer\\Config::disableProcessTimeout",
"@cs"
],
"cs": "php-cs-fixer fix --ansi --verbose --dry-run --diff",
"cs-fix": "php-cs-fixer fix --ansi --verbose --diff",
"style": "@cs-fix"
},
"config": {
"allow-plugins": {
"phpstan/extension-installer": true
}
},
"support": {
"forum": "https://github.com/datamweb/shield-oauth/discussions",
"source": "https://github.com/datamweb/shield-oauth",
"issues": "https://github.com/datamweb/shield-oauth/issues",
"docs": "https://www.shield-oauth.codeigniter4.ir"
"cs": "php-cs-fixer fix --ansi --verbose --dry-run --diff",
"cs-fix": "php-cs-fixer fix --ansi --verbose --diff",
"style": "@cs-fix"
},
"config": {
"allow-plugins": {
"phpstan/extension-installer": true
}
},
"support": {
"forum": "https://github.com/datamweb/shield-oauth/discussions",
"source": "https://github.com/datamweb/shield-oauth",
"issues": "https://github.com/datamweb/shield-oauth/issues",
"docs": "https://www.shield-oauth.codeigniter4.ir"
}
}
41 changes: 21 additions & 20 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
includes:
- phpstan-baseline.php
- phpstan-baseline.php
parameters:
tmpDir: build/phpstan
level: 6
paths:
- src/
bootstrapFiles:
- vendor/codeigniter4/framework/system/Test/bootstrap.php
excludePaths:
- app/Views/*
ignoreErrors:
universalObjectCratesClasses:
- CodeIgniter\Entity
- CodeIgniter\Entity\Entity
- Faker\Generator
scanDirectories:
- vendor/codeigniter4/framework/system/Helpers
dynamicConstantNames:
- APP_NAMESPACE
- CI_DEBUG
- ENVIRONMENT
tmpDir: build/phpstan
level: 6
paths:
- src/
bootstrapFiles:
- vendor/codeigniter4/framework/system/Test/bootstrap.php
excludePaths:
- app/Views/*
ignoreErrors:
universalObjectCratesClasses:
- CodeIgniter\Entity
- CodeIgniter\Entity\Entity
- Faker\Generator
scanDirectories:
- vendor/codeigniter4/framework/system/Helpers
- vendor/codeigniter4/settings/src/Helpers
dynamicConstantNames:
- APP_NAMESPACE
- CI_DEBUG
- ENVIRONMENT
10 changes: 5 additions & 5 deletions src/Controllers/OAuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function redirectOAuth(string $oauthName): RedirectResponse
return redirect()->to(config('Auth')->loginRedirect());
}

if (config('ShieldOAuthConfig')->oauthConfigs[$oauthName]['allow_login'] === false) {
if (setting('ShieldOAuthConfig.oauthConfigs')[$oauthName]['allow_login'] === false) {
$errorText = 'ShieldOAuthLang.' . ucfirst($oauthName) . '.not_allow';

return redirect()->to(config('Auth')->logoutRedirect())->with('error', lang($errorText));
Expand Down Expand Up @@ -93,7 +93,7 @@ public function callBack(): RedirectResponse
$userid = $this->syncingUserInfo($find, $updateFields);
} else {
// Check config setting first to see if it can register automatically or not
if (config('ShieldOAuthConfig')->oauthConfigs[$oauthName]['allow_register'] === false) {
if (setting('ShieldOAuthConfig.oauthConfigs')[$oauthName]['allow_register'] === false) {
return redirect()->to(config('Auth')->logoutRedirect())->with('error', lang('ShieldOAuthLang.Callback.account_not_found', [$userInfo->email]));
}

Expand Down Expand Up @@ -143,7 +143,7 @@ private function checkAntiForgery(string $state): bool
private function checkExistenceUser(array $find = []): bool
{
$users = model('ShieldOAuthModel');
// $find = ['email' => $this->userInfo()->email];

$findUser = $users->findByCredentials($find);

$this->userExist = $findUser;
Expand All @@ -164,10 +164,10 @@ private function syncingUserInfo(array $find = [], array $updateFields = []): in
$users = model('ShieldOAuthModel');
$user = $users->findByCredentials($find);

$syncingUserInfo = config('ShieldOAuthConfig')->syncingUserInfo;
if ($syncingUserInfo === true) {
if (setting('ShieldOAuthConfig.syncingUserInfo') === true) {
$user->fill($updateFields);
}

$users->save($user);

return $user->id;
Expand Down
Loading