The lock screen is a simple security feature that works as locking overlay over the NOVA dashboard. If the user is idle for given timeout, the lockscreen will be activated automatically. Then the user needs to enter login password again to continue their session.
-
Run composer
composer require lahirulhr/nova-lock-screen
to install the package -
Publish config (Optional)
php artisan vendor:publish --tag="nova-lock-screen.config"
-
Use
LockScreen
trait in User model
use Lahirulhr\NovaLockScreen;
class User extends Model {
use LockScreen;
// ...
}
- Register the Tool in Nova service provider
use Lahirulhr\NovaLockScreen\NovaLockScreen;
public function tools()
{
return [
// ... ,
new NovaLockScreen,
];
}
- Register middleware in
nova.php
'middleware' => [
// ... ,
\Lahirulhr\NovaLockScreen\Http\Middleware\LockScreen::class,
],
- Done
<?php
// config for Nova Lock Screen
return [
// master lock
'enabled' => true,
// auth guard for lock screen
'guard' => 'web',
// if user has been inactive for this long time, the app will be locked
'lock_timeout' => 15, // second
// default background image for lock screen
'background_image' => 'https://magnificentsrilanka.com/wp-content/uploads/2022/01/sigiriya-from-pidurangala-1.jpg',
// these urls are not locked by lock screen
'excluded_urls' => [
//
],
// set custom url for lock screen
'lock_url' => 'nova-lock-screen',
];
you can override default background image by overriding getLockScreenImage()
method in User model
public function getLockScreenImage():String
{
return 'url\to\image.jpg';
}
use lockScreenEnabled()
method to override default lock status settings
public function lockScreenEnabled():bool
{
return false;
}
use lockScreenTimeout()
method to override default lock status settings
public function lockScreenTimeout():int
{
return 60*10; // seconds
}
The lock screen page is built with Blade views. You can copy them into your resource directory by running php artisan vendor:publish --tag="nova-lock-screen.views"
command
then customize them as you want.
The MIT License (MIT). Please see License File for more information.