Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
L
Liman MYS - Çekirdek
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
liman
Liman MYS - Çekirdek
Commits
4409b932
Kaydet (Commit)
4409b932
authored
Tem 22, 2019
tarafından
Baran Sekin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added SessionTimeout Middleware
üst
8714668d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
87 additions
and
2 deletions
+87
-2
.env
.env
+1
-1
Kernel.php
app/Http/Kernel.php
+1
-0
SessionTimeout.php
app/Http/Middleware/SessionTimeout.php
+84
-0
session.php
config/session.php
+1
-1
No files found.
.env
Dosyayı görüntüle @
4409b932
...
...
@@ -16,7 +16,7 @@ DB_PATH=/liman/database/liman.sqlite
BROADCAST_DRIVER=log
CACHE_DRIVER=array
SESSION_DRIVER=file
SESSION_LIFETIME=1
20
SESSION_LIFETIME=1
QUEUE_DRIVER=database
...
...
app/Http/Kernel.php
Dosyayı görüntüle @
4409b932
...
...
@@ -13,6 +13,7 @@ class Kernel extends HttpKernel
Middleware\TrimStrings
::
class
,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull
::
class
,
// \App\Http\Middleware\TrustProxies::class,
\App\Http\Middleware\SessionTimeout
::
class
,
];
protected
$middlewareGroups
=
[
...
...
app/Http/Middleware/SessionTimeout.php
0 → 100644
Dosyayı görüntüle @
4409b932
<?php
namespace
App\Http\Middleware
;
use
Closure
;
use
Illuminate\Session\Store
;
use
Illuminate\Support\Facades\Auth
;
use
Illuminate\Support\Facades\Config
;
class
SessionTimeout
{
/**
* Instance of Session Store
* @var session
*/
protected
$session
;
/**
* Time for user to remain active, set to 900secs( 15minutes )
* @var timeout
*/
protected
$timeout
=
900
;
public
function
__construct
(
Store
$session
){
$this
->
session
=
$session
;
$this
->
redirectUrl
=
'auth/login'
;
$this
->
sessionLabel
=
'warning'
;
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public
function
handle
(
$request
,
Closure
$next
)
{
if
(
!
$this
->
session
->
has
(
'lastActivityTime'
))
{
$this
->
session
->
put
(
'lastActivityTime'
,
time
());
}
else
if
(
time
()
-
$this
->
session
->
get
(
'lastActivityTime'
)
>
$this
->
getTimeOut
())
{
$this
->
session
->
forget
(
'lastActivityTime'
);
Auth
::
logout
();
return
redirect
(
$this
->
getRedirectUrl
())
->
with
([
$this
->
getSessionLabel
()
=>
'You have been inactive for '
.
$this
->
timeout
/
60
.
' minutes ago.'
]);
}
$this
->
session
->
put
(
'lastActivityTime'
,
time
());
return
$next
(
$request
);
}
/**
* Get timeout from laravel default's session lifetime, if it's not set/empty, set timeout to 15 minutes
* @return int
*/
private
function
getTimeOut
()
{
return
(
$this
->
lifetime
)
?:
$this
->
timeout
;
}
/**
* Get redirect url from env file
* @return string
*/
private
function
getRedirectUrl
()
{
return
(
env
(
'SESSION_TIMEOUT_REDIRECTURL'
))
?:
$this
->
redirectUrl
;
}
/**
* Get Session label from env file
* @return string
*/
private
function
getSessionLabel
()
{
return
(
env
(
'SESSION_LABEL'
))
?:
$this
->
sessionLabel
;
}
}
\ No newline at end of file
config/session.php
Dosyayı görüntüle @
4409b932
...
...
@@ -33,7 +33,7 @@ return [
'lifetime'
=>
env
(
'SESSION_LIFETIME'
,
120
),
'expire_on_close'
=>
fals
e
,
'expire_on_close'
=>
tru
e
,
/*
|--------------------------------------------------------------------------
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment