Skip to content

Commit

Permalink
feat: keep alive disabling
Browse files Browse the repository at this point in the history
  • Loading branch information
Sébastien HEYD committed Oct 2, 2024
1 parent 00b6539 commit bc46bb0
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 7 deletions.
38 changes: 32 additions & 6 deletions docs/docs/8.x/configuration/app.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,34 @@ The `config/boilerplate/app.php` file allows to define the general parameters of

```php
<?php

return [
// Backend routes prefix. Ex: "admin" => "http://..../admin"
'prefix' => 'admin',
'prefix' => 'admin',

// Backend domain if different as current domain. Ex: "admin.mydomain.tld"
'domain' => '',
'domain' => '',

// Redirect to this route after login
'redirectTo' => 'boilerplate.dashboard',
'redirectTo' => 'boilerplate.dashboard',

// Activating daily logs and showing log viewer
'logs' => true,
'logs' => true,

// When set to true, allows admins to view the site as a user of their choice
'allowImpersonate' => false,

// If true, the session will be kept alive and the user must log out
'keepalive' => true,

// Allows to generate text with ChatGPT in TinyMCE
'openai' => [
'key' => env('OPENAI_API_KEY'),
'model' => 'gpt-3.5-turbo',
'organization' => env('OPENAI_API_ORGANIZATION'),
],
];

```
---

Expand Down Expand Up @@ -76,4 +88,18 @@ Log viewer is only visible by administrators by default.
When `allowImpersonate` is set to true, admins are allowed to view the site as the user of their choice by using a
switch in the navbar.

> You can't switch to an admin user
> You can't switch to an admin user
---

## keepalive

Allows enabling or disabling session keep alive. If the value is set to `true`, the session will be maintained until the user logs out.

Conversely, if the value is set to `false`, the user will be logged out when the session expires.

---

## openai

Allows setting variables for using ChatGPT in TinyMCE
3 changes: 3 additions & 0 deletions src/config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
// When set to true, allows admins to view the site as a user of their choice
'allowImpersonate' => false,

// If true, the session will be kept alive and the user must log out
'keepalive' => true,

// Allows to generate text with ChatGPT in TinyMCE
'openai' => [
'key' => env('OPENAI_API_KEY'),
Expand Down
2 changes: 2 additions & 0 deletions src/resources/views/gpt/layout.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
@component('boilerplate::minify')
<script>
$.ajaxSetup({headers:{'X-CSRF-TOKEN':'{{ csrf_token() }}'}});
@if(config('boilerplate.app.keepalive', false))
var session={
keepalive:"{{ route('boilerplate.keepalive', null, false) }}",
expire:{{ time() + config('session.lifetime') * 60 }},
lifetime:{{ config('session.lifetime') * 60 }},
id:"{{ session()->getId() }}"
};
@endif
</script>
@endcomponent
@stack('plugin-js')
Expand Down
2 changes: 2 additions & 0 deletions src/resources/views/layout/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@
var bpRoutes={
settings:"{{ route('boilerplate.user.settings',null,false) }}"
};
@if(config('boilerplate.app.keepalive', false))
var session={
keepalive:"{{ route('boilerplate.keepalive', null, false) }}",
expire:{{ time() + config('session.lifetime') * 60 }},
lifetime:{{ config('session.lifetime') * 60 }},
id:"{{ session()->getId() }}"
};
@endif
</script>
@endcomponent
@stack('plugin-js')
Expand Down
4 changes: 3 additions & 1 deletion src/routes/boilerplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@
Route::get('/demo', [DemoController::class, 'index'])->name('demo');

// Session keep-alive
Route::post('keep-alive', [UsersController::class, 'keepAlive'])->name('keepalive');
if (config('boilerplate.app.keepalive', false)) {
Route::post('keep-alive', [UsersController::class, 'keepAlive'])->name('keepalive');
}

// Datatables
Route::post('datatables/{slug}', [DatatablesController::class, 'make'])->name('datatables');
Expand Down
1 change: 1 addition & 0 deletions tests/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
'app.url' => 'http://localhost',
'app.fallback_locale' => 'en',
'boilerplate.app.locale' => 'en',
'boilerplate.app.keepalive' => 'true',
'boilerplate.locale.switch' => true,
'boilerplate.locale.allowed' => ['fr'],
'boilerplate.app.allowImpersonate' => true,
Expand Down

0 comments on commit bc46bb0

Please sign in to comment.