Merge branch 'ticket660' into develop
This commit is contained in:
commit
bb4dbd1017
13 changed files with 2464 additions and 1923 deletions
|
|
@ -15,7 +15,7 @@ class Kernel extends HttpKernel
|
|||
* @var array
|
||||
*/
|
||||
protected $middleware = [
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
\App\Http\Middleware\StartSession::class,
|
||||
\App\Http\Middleware\TrustProxies::class,
|
||||
\Fruitcake\Cors\HandleCors::class,
|
||||
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
|
||||
|
|
|
|||
21
app/Http/Middleware/StartSession.php
Normal file
21
app/Http/Middleware/StartSession.php
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Session\Middleware\StartSession as MiddlewareStartSession;
|
||||
|
||||
class StartSession extends MiddlewareStartSession
|
||||
{
|
||||
/**
|
||||
* Save the session data to storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return void
|
||||
*/
|
||||
protected function saveSession($request)
|
||||
{
|
||||
if (!$request->is('/ping')) {
|
||||
parent::saveSession($request);
|
||||
}
|
||||
}
|
||||
}
|
||||
4246
package-lock.json
generated
4246
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -11,6 +11,7 @@
|
|||
"prod": "npm run production"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/plugin-transform-async-to-generator": "^7.16.8",
|
||||
"axios": "^0.21.1",
|
||||
"bootstrap": "^5.0.2",
|
||||
"cross-env": "^7.0",
|
||||
|
|
|
|||
1
resources/js/app.js
vendored
1
resources/js/app.js
vendored
|
|
@ -1,4 +1,5 @@
|
|||
require('./bootstrap');
|
||||
require('./session_watch');
|
||||
//window.Vue = require('vue/dist/vue.min.js');
|
||||
import Vue from 'vue'
|
||||
import moment from 'moment'
|
||||
|
|
|
|||
16
resources/js/modules/session_pinger.js
vendored
Normal file
16
resources/js/modules/session_pinger.js
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import axios from "axios"
|
||||
|
||||
export default {
|
||||
methods: {
|
||||
async validateSession(callback) {
|
||||
axios.get('/ping').then(response => {
|
||||
if (response.status !== 200) {
|
||||
callback()
|
||||
}
|
||||
}).catch(() => {
|
||||
callback()
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
29
resources/js/session_watch.js
vendored
Normal file
29
resources/js/session_watch.js
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
document.addEventListener('DOMContentLoaded', () => {
|
||||
let sessionValidates = document.querySelectorAll('[data-validate-session]'),
|
||||
validateSession = require('./modules/session_pinger').default.methods.validateSession,
|
||||
sessionInvalidAction = () => {
|
||||
Swal.fire({
|
||||
title: 'Session expirée',
|
||||
text: 'Votre session à expiré vous devrez recharger la page pour soumettre des informations.',
|
||||
icon: 'error'
|
||||
})
|
||||
clearTimeout(timeOut)
|
||||
},
|
||||
timer = 10000,
|
||||
timeOut
|
||||
|
||||
let timerAction = () => {
|
||||
validateSession(sessionInvalidAction)
|
||||
timeOut = setTimeout(timerAction, timer)
|
||||
}
|
||||
|
||||
if (window.__SESSION_WATCH) {
|
||||
timerAction()
|
||||
}
|
||||
|
||||
for (let element of sessionValidates) {
|
||||
element.addEventListener('click', () => {
|
||||
validateSession(sessionInvalidAction)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
|
@ -48,5 +48,9 @@
|
|||
<script src="{{ asset('js/app.js') }}"></script>
|
||||
@stack('scripts')
|
||||
@crudPoliciesJS()
|
||||
@auth
|
||||
{{-- JS SESSION ALERT IF SESSION TIMEOUT --}}
|
||||
<script>var __SESSION_WATCH = true;</script>
|
||||
@endauth
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@
|
|||
<h4>
|
||||
{{ __('Suivi') }}
|
||||
@can('createMessage', $ticket)
|
||||
<button type="button" class="btn btn-sm btn-primary float-end" data-bs-toggle="modal" data-bs-target="#messageModal">
|
||||
<button data-validate-session type="button" class="btn btn-sm btn-primary float-end" data-bs-toggle="modal" data-bs-target="#messageModal">
|
||||
{{ __('Répondre') }}
|
||||
</button>
|
||||
<div class="modal fade" id="messageModal" tabindex="-1" aria-labelledby="messageModalLabel" aria-hidden="true">
|
||||
|
|
@ -104,7 +104,7 @@
|
|||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="reset" class="btn btn-sm btn-danger" data-bs-dismiss="modal">{{ __('Fermer') }}</button>
|
||||
<button type="submit" class="btn btn-sm btn-success">{{ __('Envoyer') }}</button>
|
||||
<button data-validate-session type="submit" class="btn btn-sm btn-success">{{ __('Envoyer') }}</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
|
@ -161,4 +161,4 @@
|
|||
</ul>
|
||||
</div>
|
||||
@endif
|
||||
@endsection
|
||||
@endsection
|
||||
|
|
|
|||
|
|
@ -1,19 +1 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| API Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here is where you can register API routes for your application. These
|
||||
| routes are loaded by the RouteServiceProvider within a group which
|
||||
| is assigned the "api" middleware group. Enjoy building your API!
|
||||
|
|
||||
*/
|
||||
|
||||
Route::middleware('auth:api')->get('/user', function (Request $request) {
|
||||
return $request->user();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,18 +1 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Broadcast;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Broadcast Channels
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may register all of the event broadcasting channels that your
|
||||
| application supports. The given channel authorization callbacks are
|
||||
| used to check if an authenticated user can listen to the channel.
|
||||
|
|
||||
*/
|
||||
|
||||
Broadcast::channel('App.Models.User.{id}', function ($user, $id) {
|
||||
return (int)$user->id === (int)$id;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,19 +1 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Foundation\Inspiring;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Console Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This file is where you may define all of your Closure based console
|
||||
| commands. Each Closure is bound to a command instance allowing a
|
||||
| simple approach to interacting with each command's IO methods.
|
||||
|
|
||||
*/
|
||||
|
||||
Artisan::command('inspire', function () {
|
||||
$this->comment(Inspiring::quote());
|
||||
})->purpose('Display an inspiring quote');
|
||||
|
|
|
|||
|
|
@ -36,6 +36,14 @@ Route::middleware(['throttle:credentials'])->group(function () {
|
|||
]);
|
||||
});
|
||||
|
||||
// Session Ping
|
||||
Route::get('/ping', function () {
|
||||
if (request()->isJson()) {
|
||||
abort(404);
|
||||
}
|
||||
return auth()->check() ? response()->json() : response()->json([], 401);
|
||||
})->withoutMiddleware('auth');
|
||||
|
||||
Route::middleware(['auth'])->group(function () {
|
||||
|
||||
// Logged user actions
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue