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

Package admin dev #137

Merged
merged 94 commits into from
Mar 26, 2024
Merged
Changes from 1 commit
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
8bce6df
Merge pull request #116 from xxl4/main_de
xxl4 Mar 14, 2024
6676f6d
#117 add lp admin function
xxl4 Mar 14, 2024
ffce579
#117 fix the create and edit page
xxl4 Mar 14, 2024
5ecbc90
#117 fix the create and edit page
xxl4 Mar 14, 2024
2ae97e1
fix the lp edit page
xxl4 Mar 14, 2024
9314634
fix delete
xxl4 Mar 14, 2024
fd8ed81
#96 add base manage package
xxl4 Mar 14, 2024
996d476
#96 add base manage package
xxl4 Mar 14, 2024
d3fb68b
#96 add base manage package
xxl4 Mar 14, 2024
ecbaa2e
#96 add base manage package
xxl4 Mar 14, 2024
a62f99a
#96 fix the manage url name
xxl4 Mar 14, 2024
e80d4ff
#96 fix the manage url name
xxl4 Mar 14, 2024
fc209a7
#96 fix the manage url name
xxl4 Mar 14, 2024
0ad83cc
#96 fix the manage url name
xxl4 Mar 14, 2024
bb1d971
fix manage helper
xxl4 Mar 15, 2024
2370bef
fix the version name
xxl4 Mar 15, 2024
b8f1223
update
xxl4 Mar 17, 2024
9ae1cc4
add manage tests dir
xxl4 Mar 17, 2024
559cc1b
add manage tests dir
xxl4 Mar 17, 2024
1d36e95
add data grid
xxl4 Mar 18, 2024
8820106
add data grid
xxl4 Mar 18, 2024
a70c5d1
fix
xxl4 Mar 18, 2024
ba3a91c
fix manage composer
xxl4 Mar 18, 2024
47145d4
fix session base
xxl4 Mar 18, 2024
f647ac9
fix session base
xxl4 Mar 18, 2024
16937dc
fix manage user
xxl4 Mar 18, 2024
be3a515
add lang
xxl4 Mar 18, 2024
bb1227c
add manage url config
xxl4 Mar 18, 2024
6ea51f4
fix session to new auth
xxl4 Mar 18, 2024
0a93703
fix manage
xxl4 Mar 18, 2024
e095e47
fix user module
xxl4 Mar 18, 2024
3ff09d2
fix support manage themes
xxl4 Mar 18, 2024
62a06a6
add version
xxl4 Mar 18, 2024
ab28a9b
add new themes
xxl4 Mar 18, 2024
c651ab4
fix the manage
xxl4 Mar 18, 2024
e1c974e
fix the new admin
xxl4 Mar 19, 2024
9b653df
fix the old admin
xxl4 Mar 19, 2024
ff9ffed
fix del
xxl4 Mar 19, 2024
837c293
fix old admin
xxl4 Mar 19, 2024
b14c8a5
fix the new admin
xxl4 Mar 19, 2024
88bd080
fix
xxl4 Mar 19, 2024
287e811
fix
xxl4 Mar 19, 2024
e50ca4d
fix
xxl4 Mar 19, 2024
66c6a94
fix
xxl4 Mar 19, 2024
166d90f
fix delete
xxl4 Mar 19, 2024
85207e2
#123 fix the user login
xxl4 Mar 19, 2024
73a51f0
#123 fix the user login
xxl4 Mar 19, 2024
703af73
#123 fix the user login
xxl4 Mar 19, 2024
0a1e829
#123 fix the user login
xxl4 Mar 19, 2024
eadbe6f
fix new admin
xxl4 Mar 19, 2024
b872a32
add adminLTE
xxl4 Mar 19, 2024
38da0e3
admin menu
xxl4 Mar 19, 2024
fc2284a
fix manifest json
xxl4 Mar 19, 2024
4897cdf
fix the icon
xxl4 Mar 19, 2024
d856d14
fix the layout
xxl4 Mar 19, 2024
d6a4c3c
add footer layout
xxl4 Mar 19, 2024
1916acc
fix the menu
xxl4 Mar 19, 2024
3b70279
fix the dashboard
xxl4 Mar 19, 2024
6577aa2
disable the dark mode
xxl4 Mar 20, 2024
81ad74c
Merge pull request #128 from xxl4/package_lp_dev
xxl4 Mar 20, 2024
cd93547
fix delete lp page
xxl4 Mar 20, 2024
13fbe3e
fix add new lp page
xxl4 Mar 20, 2024
ec7c245
fix change the controller
xxl4 Mar 20, 2024
5ade6b3
fix the layout
xxl4 Mar 20, 2024
c917cbd
fix add base sale order
xxl4 Mar 20, 2024
c692dec
fix add join function for ssp
xxl4 Mar 20, 2024
fcf7278
fix add key
xxl4 Mar 20, 2024
8a94525
fix
xxl4 Mar 20, 2024
daf9132
move the db to SSP file
xxl4 Mar 20, 2024
b7d7b35
fix the order page
xxl4 Mar 20, 2024
fea72c4
fix manage module
xxl4 Mar 20, 2024
713461d
fix order sales
xxl4 Mar 20, 2024
8face1d
fix the dashboard
xxl4 Mar 21, 2024
db5c473
产品页面
gekaiyuan Mar 21, 2024
5255e45
Merge pull request #130 from xxl4/main_de
xxl4 Mar 21, 2024
cc2a2b3
fix the order select
xxl4 Mar 21, 2024
c657946
fix the order select
xxl4 Mar 21, 2024
e8130f1
fix
xxl4 Mar 21, 2024
6a41b09
fix show order detail
xxl4 Mar 21, 2024
6b18f4e
fix order page
xxl4 Mar 21, 2024
b3f0545
fix remove the old admin
xxl4 Mar 21, 2024
0ba0c83
提交编辑页面
gekaiyuan Mar 21, 2024
d98ff33
Merge branch 'package_admin_dev' of github.com:xxl4/NexaMerchant into…
gekaiyuan Mar 21, 2024
897377e
show track_number
xxl4 Mar 22, 2024
d92ccc8
show track_number
xxl4 Mar 22, 2024
8fe603b
提交样式配置文件和编辑页面
gekaiyuan Mar 22, 2024
b7b30db
Merge pull request #135 from xxl4/main_de
xxl4 Mar 25, 2024
182c186
fix the database seeders
xxl4 Mar 25, 2024
1f236e9
fix package manage order
xxl4 Mar 25, 2024
02baa2b
ix
xxl4 Mar 25, 2024
5210b2b
fix remove
xxl4 Mar 25, 2024
90b2f36
ix
xxl4 Mar 25, 2024
fa616e7
fix the old admin testcase
xxl4 Mar 26, 2024
6a9fddf
fix the old admin testcase
xxl4 Mar 26, 2024
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
Prev Previous commit
Next Next commit
fix user module
  • Loading branch information
xxl4 committed Mar 18, 2024
commit e095e47a5471bdeb2d70320e47357853cc6387e3
3 changes: 2 additions & 1 deletion packages/Webkul/User/composer.json
Original file line number Diff line number Diff line change
@@ -19,7 +19,8 @@
"Webkul\\User\\Providers\\UserServiceProvider"
],
"aliases": {
"Bouncer": "Webkul\\User\\Facades\\Bouncer"
"Bouncer": "Webkul\\User\\Facades\\Bouncer",
"BouncerManage": "Webkul\\User\\Facades\\BouncerManage"
}
}
},
47 changes: 47 additions & 0 deletions packages/Webkul/User/src/BouncerManage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace Webkul\User;

class BouncerManage
{
/**
* Checks if user allowed or not for certain action
*
* @param string $permission
* @return void
*/
public function hasPermission($permission)
{
if (
auth()->guard('manage')->check()
&& auth()->guard('manage')->user()->role->permission_type == 'all'
) {
return true;
} else {
if (
! auth()->guard('manage')->check()
|| ! auth()->guard('manage')->user()->hasPermission($permission)
) {
return false;
}
}

return true;
}

/**
* Checks if user allowed or not for certain action
*
* @param string $permission
* @return void
*/
public static function allow($permission)
{
if (
! auth()->guard('manage')->check()
|| ! auth()->guard('manage')->user()->hasPermission($permission)
) {
abort(401, 'This action is unauthorized');
}
}
}
7 changes: 7 additions & 0 deletions packages/Webkul/User/src/Contracts/Manage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Webkul\User\Contracts;

interface Manage
{
}
18 changes: 18 additions & 0 deletions packages/Webkul/User/src/Facades/BouncerManage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Webkul\User\Facades;

use Illuminate\Support\Facades\Facade;

class BouncerManage extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'bouncer_manage';
}
}
95 changes: 95 additions & 0 deletions packages/Webkul/User/src/Http/Middleware/BouncerManage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?php

namespace Webkul\User\Http\Middleware;

use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Event;

class BouncerManage
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, \Closure $next, $guard = 'manage')
{
if (! auth()->guard($guard)->check()) {
return redirect()->route('manage.session.create');
}

Event::dispatch('bagisto.updates.check');

/**
* If user status is changed by manage. Then session should be
* logged out.
*/
if (! (bool) auth()->guard($guard)->user()->status) {
auth()->guard($guard)->logout();

return redirect()->route('manage.session.create');
}

/**
* If somehow the user deleted all permissions, then it should be
* auto logged out and need to contact the administrator again.
*/
if ($this->isPermissionsEmpty()) {
auth()->guard('manage')->logout();

session()->flash('error', __('manage::app.error.403.message'));

return redirect()->route('manage.session.create');
}

return $next($request);
}

/**
* Check for user, if they have empty permissions or not except admin.
*
* @return bool
*/
public function isPermissionsEmpty()
{
if (! $role = auth()->guard('manage')->user()->role) {
abort(401, 'This action is unauthorized.');
}

if ($role->permission_type === 'all') {
return false;
}

if (
$role->permission_type !== 'all'
&& empty($role->permissions)
) {
return true;
}

$this->checkIfAuthorized();

return false;
}

/**
* Check authorization.
*
* @return null
*/
public function checkIfAuthorized()
{
$acl = app('acl');

if (! $acl) {
return;
}

if (isset($acl->roles[Route::currentRouteName()])) {
bouncer()->allow($acl->roles[Route::currentRouteName()]);
}
}
}
8 changes: 8 additions & 0 deletions packages/Webkul/User/src/Http/helpers.php
Original file line number Diff line number Diff line change
@@ -5,4 +5,12 @@ function bouncer()
return app()->make(\Webkul\User\Bouncer::class);
}
}

if (! function_exists('bouncer_manage')) {
function bouncer_manage()
{
return app()->make(\Webkul\User\BouncerManage::class);
}
}

?>
7 changes: 7 additions & 0 deletions packages/Webkul/User/src/Providers/UserServiceProvider.php
Original file line number Diff line number Diff line change
@@ -6,7 +6,9 @@
use Illuminate\Foundation\AliasLoader;
use Illuminate\Routing\Router;
use Webkul\User\Bouncer;
use Webkul\User\BouncerManage;
use Webkul\User\Facades\Bouncer as BouncerFacade;
use Webkul\User\Facades\BouncerManage as BouncerManageFacade;
use Webkul\User\Http\Middleware\Bouncer as BouncerMiddleware;

class UserServiceProvider extends ServiceProvider
@@ -48,5 +50,10 @@ protected function registerBouncer()
$this->app->singleton('bouncer', function () {
return new Bouncer();
});

$loader->alias('BouncerManage', BouncerManageFacade::class);
$this->app->singleton('bouncer_manage', function () {
return new BouncerManage();
});
}
}