Skip to content

Commit

Permalink
Merge pull request #100 from sebastienheyd/95-remove-keep-alive-session
Browse files Browse the repository at this point in the history
95 remove keep alive session
  • Loading branch information
sebastienheyd authored Oct 4, 2024
2 parents 00b6539 + 0d51356 commit 50504f4
Show file tree
Hide file tree
Showing 22 changed files with 155 additions and 61 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
11 changes: 8 additions & 3 deletions src/Controllers/Auth/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,18 @@ public function redirectTo()
*
* @return View|Redirector
*/
public function showLoginForm()
public function showLoginForm(Request $request)
{
$userModel = config('auth.providers.users.model');

if ($userModel::whereHasRole('admin')->count() === 0) {
return redirect(route('boilerplate.register'));
}

return view('boilerplate::auth.login');
return view('boilerplate::auth.login', [
'expired' => $request->get('expired', false),
'redirect' => $request->get('path', false),
]);
}

/**
Expand Down Expand Up @@ -77,9 +80,11 @@ protected function sendLoginResponse(Request $request)
if ($this->authenticated($request, $this->guard()->user())) {
$this->guard()->user()->update(['last_login' => Carbon::now()->toDateTimeString()]);

$path = $request->post('redirect');

return $request->wantsJson()
? new JsonResponse([], 204)
: redirect()->intended($this->redirectPath());
: redirect()->intended($path ?: $this->redirectPath());
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/Controllers/GptController.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ private function processPrompt($request)
*
* @param Request $request
* @return void
*
* @codeCoverageIgnore
*/
public function stream(Request $request)
{
Expand Down Expand Up @@ -194,6 +196,8 @@ public function stream(Request $request)
* @param $prompt
* @param $callback
* @return bool|string
*
* @codeCoverageIgnore
*/
private function sendRequest($prompt, $callback)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/Users/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ public function getAvatarFromGravatar()
*
* @param Request $request
*/
public function keepAlive(Request $request)
public function sessionKeepAlive(Request $request)
{
if ($request->post('id') !== null) {
session()->setId($request->post('id'));
Expand Down
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
7 changes: 4 additions & 3 deletions src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
},
"devDependencies": {
"clean-webpack-plugin": "^3.0.0",
"husky": "^9.1.6",
"laravel-echo": "^1.11.7",
"laravel-mix": "^6.0.42",
"postcss": "^8.4.6",
"pusher-js": "^7.1.1-beta",
"resolve-url-loader": "^3.1.4",
"sass": "1.32.13",
"sass-loader": "^12.6.0",
"husky": "^9.1.6"
"sass-loader": "^12.6.0"
},
"dependencies": {
"@fortawesome/fontawesome-free": "^6.1.1",
Expand All @@ -35,6 +35,7 @@
"moment": "^2.30.1",
"patch-package": "^8.0.0",
"spectrum-colorpicker2": "^2.0.10",
"tinymce": "^5.10.9"
"tinymce": "^5.10.9",
"worker-timers": "^8.0.7"
}
}
2 changes: 1 addition & 1 deletion src/public/boilerplate.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/public/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"/bootstrap.min.js": "/bootstrap.min.js?id=97e6c8c49b931c59c6c2da28d0ce5efe",
"/admin-lte.min.js": "/admin-lte.min.js?id=c85385f67373feb418b4d9b031c7fe5c",
"/boilerplate.min.js": "/boilerplate.min.js?id=a8bf041ba64d0bda7f2539906d53a370",
"/boilerplate.min.js": "/boilerplate.min.js?id=dcbfff59e206dde9493a120546040204",
"/avatar.min.js": "/avatar.min.js?id=b88909deff24143b389d29219a8c47a9",
"/dashboard.min.js": "/dashboard.min.js?id=6513cfc47ed3cfac4507bb27ea361320",
"/plugins/codemirror/jquery.codemirror.min.js": "/plugins/codemirror/jquery.codemirror.min.js?id=aa557346ea5f36bf351fd2fccc8fa8d8",
Expand Down
Loading

0 comments on commit 50504f4

Please sign in to comment.