Skip to content

Commit 35a654e

Browse files
authored
Merge pull request #4 from niladam/feature/rename-and-improve
2 parents 7eac6a2 + 926eddc commit 35a654e

File tree

12 files changed

+26
-135
lines changed

12 files changed

+26
-135
lines changed

.github/workflows/phpstan.yml

Lines changed: 0 additions & 26 deletions
This file was deleted.

README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
# A filament plugin that automatically logs out your users if they are idle.
1+
# A filament plugin that auto logs out your users if they are idle. Works with multiple tabs.
2+
3+
<br>
24

35
[![Latest Version on Packagist](https://img.shields.io/packagist/v/niladam/filament-auto-logout.svg?style=flat-square)](https://packagist.org/packages/niladam/filament-auto-logout)
4-
[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/niladam/filament-auto-logout/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/niladam/filament-auto-logout/actions?query=workflow%3Arun-tests+branch%3Amain)
56
[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/niladam/filament-auto-logout/fix-php-code-styling.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/niladam/filament-auto-logout/actions?query=workflow%3A"Fix+PHP+code+styling"+branch%3Amain)
67
[![Total Downloads](https://img.shields.io/packagist/dt/niladam/filament-auto-logout.svg?style=flat-square)](https://packagist.org/packages/niladam/filament-auto-logout)
78

89

9-
10-
A small filament plugin that logs out your users if they are idle.
11-
1210
## Installation
1311

1412
You can install the package via composer:
@@ -80,11 +78,11 @@ return [
8078

8179
```php
8280
use Carbon\Carbon;
83-
use Niladam\FilamentAutoLogout\FilamentAutoLogoutPlugin;
81+
use Niladam\FilamentAutoLogout\AutoLogoutPlugin;
8482

8583
$panel
8684
->plugins([
87-
FilamentAutoLogoutPlugin::make()
85+
AutoLogoutPlugin::make()
8886
->positionLeft() // Align the time left box to the left. Defaults to right.
8987
->disableIf(fn () => auth()->id() === 1) // Disable the user with ID 1
9088
->logoutAfter(Carbon::SECONDS_PER_MINUTE * 5) // Logout the user after 5 minutes

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "niladam/filament-auto-logout",
3-
"description": "A filament plugin that automatically logs out your users if they are idle.",
3+
"description": "A filament plugin that auto logs out your users if they are idle.",
44
"keywords": [
55
"laravel",
66
"filament-auto-logout",
@@ -44,7 +44,7 @@
4444
"extra": {
4545
"laravel": {
4646
"providers": [
47-
"Niladam\\FilamentAutoLogout\\FilamentAutoLogoutServiceProvider"
47+
"Niladam\\FilamentAutoLogout\\AutoLogoutServiceProvider"
4848
]
4949
}
5050
}

config/filament-auto-logout.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,15 @@
4646
* Currently only 'right' and 'left' (bottom) are supported
4747
*/
4848
'time_left_position' => env('FILAMENT_AUTO_LOGOUT_TIME_LEFT_POSITION', AutoLogoutPosition::BOTTOM_RIGHT),
49+
50+
/**
51+
* The route name where the logout will be posted.
52+
*
53+
* Defaults to filament's logout route & controller, but uses a custom route name
54+
* to ensure it doesn't conflict with any other logout routes
55+
*
56+
* You can overwrite this here but ensure that the route accepts a POST request
57+
* and handles the logout process entirely.
58+
*/
59+
'auto_logout_route_name' => env('FILAMENT_AUTO_LOGOUT_ROUTE_NAME', 'filament-auto-logout-plugin-form'),
4960
];

resources/views/main.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<script src="{{ \Filament\Support\Facades\FilamentAsset::getAlpineComponentSrc('filament-auto-logout', 'niladam/filament-auto-logout') }}"></script>
33
<form id="auto-logout-form"
44
data-auto-logout-enabled="{{ $enabled }}"
5-
action="{{ route('filament.app.auth.logout') }}"
5+
action="{{ route($route_name) }}"
66
data-duration="{{ $duration }}"
77
data-warn-before="{{ $warn_before }}"
88
data-show-timeleft="{{ $show_time_left }}"

src/FilamentAutoLogoutPlugin.php renamed to src/AutoLogoutPlugin.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Illuminate\Support\Facades\View;
1111
use Niladam\FilamentAutoLogout\Enums\AutoLogoutPosition;
1212

13-
class FilamentAutoLogoutPlugin implements Plugin
13+
class AutoLogoutPlugin implements Plugin
1414
{
1515
use EvaluatesClosures;
1616

@@ -57,6 +57,7 @@ protected function renderView(): string
5757
'warn_before' => $this->evaluate($this->hasWarning) ? $this->evaluate($this->warnBeforeSeconds) : 0,
5858
'position' => $this->position->getPosition(),
5959
'time_left_text' => $this->timeleftText,
60+
'route_name' => config('filament-auto-logout.auto_logout_route_name'),
6061
])->render();
6162
}
6263

src/FilamentAutoLogoutServiceProvider.php renamed to src/AutoLogoutServiceProvider.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,23 @@
22

33
namespace Niladam\FilamentAutoLogout;
44

5+
use Filament\Http\Controllers\Auth\LogoutController;
56
use Filament\Support\Assets\AlpineComponent;
67
use Filament\Support\Assets\Asset;
7-
use Filament\Support\Assets\Css;
8-
use Filament\Support\Assets\Js;
98
use Filament\Support\Facades\FilamentAsset;
9+
use Illuminate\Support\Facades\Route;
1010
use Spatie\LaravelPackageTools\Commands\InstallCommand;
1111
use Spatie\LaravelPackageTools\Package;
1212
use Spatie\LaravelPackageTools\PackageServiceProvider;
1313

14-
class FilamentAutoLogoutServiceProvider extends PackageServiceProvider
14+
class AutoLogoutServiceProvider extends PackageServiceProvider
1515
{
1616
public static string $name = 'filament-auto-logout';
1717

1818
public static string $viewNamespace = 'filament-auto-logout';
1919

2020
public function configurePackage(Package $package): void
2121
{
22-
/*
23-
* This class is a Package Service Provider
24-
*
25-
* More info: https://github.com/spatie/laravel-package-tools
26-
*/
2722
$package->name(static::$name)
2823
->hasInstallCommand(function (InstallCommand $command) {
2924
$command
@@ -44,6 +39,8 @@ public function configurePackage(Package $package): void
4439
if (file_exists($package->basePath('/../resources/views'))) {
4540
$package->hasViews(static::$viewNamespace);
4641
}
42+
43+
Route::post('auto-logout-plugin-form', LogoutController::class)->name('filament-auto-logout-plugin-form');
4744
}
4845

4946
public function packageRegistered(): void {}
@@ -69,8 +66,6 @@ protected function getAssets(): array
6966
{
7067
return [
7168
AlpineComponent::make('filament-auto-logout', __DIR__ . '/../resources/dist/filament-auto-logout.js'),
72-
// Css::make('filament-auto-logout-styles', __DIR__ . '/../resources/dist/filament-auto-logout.css'),
73-
// Js::make('filament-auto-logout-scripts', __DIR__ . '/../resources/dist/filament-auto-logout.js'),
7469
];
7570
}
7671
}

src/Testing/TestsFilamentAutoLogout.php

Lines changed: 0 additions & 13 deletions
This file was deleted.

tests/ArchTest.php

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/ExampleTest.php

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/Pest.php

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/TestCase.php

Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
 (0)