-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(http): optimize request authorization and validation (#532)
* refactor(http): optimize request authorization and validation - Remove redundant authorize() methods from request classes - Add NoAuthorizeTrait for consistent authorization logic - Implement HttpMethodTrait for HTTP method checks - Update RoleRequest with custom validation rules for code - Add token retrieval failure check in GetTokenTrait - Remove unnecessary comments and adjust imports * fix(permission): prevent broken relations after deleting menus or roles - Add deleting event handler in Menu model to detach associated roles - Update Role model to also detach associated menus when deleting * ci: update codecov file path- Change the file path for codecov action from "./tests/coverage/index.xml" to "./tests/coverage.xml/index.xml" * refactor(request): move request traits to Traits directory - Move NoAuthorizeTrait and HttpMethodTrait to Traits directory - Update namespace from Trait to Traits in multiple files - Adjust import statements in various request files to use new namespace * update UserRequest rules * ci: update Codecov and remove CodeQL workflows - Update Codecov workflow to use new file path - Remove CodeQL workflow as it's no longer needed * ci: update code coverage and simplify phone number validation - Update .gitignore to include tests/coverage directory - Modify GitHub Actions workflow to use correct coverage file path - Remove regex validation for phone number in UserRequest
- Loading branch information
Showing
20 changed files
with
123 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* This file is part of MineAdmin. | ||
* | ||
* @link https://www.mineadmin.com | ||
* @document https://doc.mineadmin.com | ||
* @contact [email protected] | ||
* @license https://github.com/mineadmin/MineAdmin/blob/master/LICENSE | ||
*/ | ||
|
||
namespace App\Http\Common\Request\Traits; | ||
|
||
use Hyperf\Validation\Request\FormRequest; | ||
|
||
/** | ||
* @mixin FormRequest | ||
*/ | ||
trait HttpMethodTrait | ||
{ | ||
public function isCreate(): bool | ||
{ | ||
return $this->isMethod('POST'); | ||
} | ||
|
||
public function isUpdate(): bool | ||
{ | ||
return $this->isMethod('PUT') || $this->isMethod('PATCH'); | ||
} | ||
|
||
public function isDelete(): bool | ||
{ | ||
return $this->isMethod('DELETE'); | ||
} | ||
|
||
public function isSearch(): bool | ||
{ | ||
return $this->isMethod('GET'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* This file is part of MineAdmin. | ||
* | ||
* @link https://www.mineadmin.com | ||
* @document https://doc.mineadmin.com | ||
* @contact [email protected] | ||
* @license https://github.com/mineadmin/MineAdmin/blob/master/LICENSE | ||
*/ | ||
|
||
namespace App\Http\Common\Request\Traits; | ||
|
||
trait NoAuthorizeTrait | ||
{ | ||
public function authorize(): bool | ||
{ | ||
return true; | ||
} | ||
} |
Oops, something went wrong.