Skip to content

Commit

Permalink
fix auth
Browse files Browse the repository at this point in the history
  • Loading branch information
xxl4 committed Nov 20, 2024
1 parent 3487e08 commit 2f00c0c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Config/menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@
*/
[
'key' => 'Apps',
'name' => 'apps::app.apps.demo',
'name' => 'Apps::app.apps.demo',
'route' => 'apps.admin.example.demo',
'sort' => 1,
'icon' => 'icon-dashboard',
'permission' => 'apps.admin.example.demo',
],
[
'key' => 'Apps.Settings',
'name' => 'apps::app.apps.Settings',
'name' => 'Apps::app.apps.Settings',
'route' => 'apps.admin.apps.setting',
'sort' => 2,
'icon' => 'icon-dashboard',
'permission' => 'apps.admin.settings.index',
'permission' => 'Apps.admin.settings.index',
]
// ],
// [
Expand Down
21 changes: 21 additions & 0 deletions src/Http/Middleware/Authenticate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
namespace NexaMerchant\Apps\Http\Middleware;
use Closure;
class Authenticate
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!auth()->guard('apps')->check()) {
return redirect()->route('apps.login');
}

return $next($request);
}
}
3 changes: 3 additions & 0 deletions src/Providers/AppsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public function boot(Router $router)
$this->loadViewsFrom(__DIR__ . '/../Resources/views', 'Apps');

$this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');

// register the apps auth middleware
$router->aliasMiddleware('apps', \NexaMerchant\Apps\Http\Middleware\Authenticate::class);


/*
Expand Down

0 comments on commit 2f00c0c

Please sign in to comment.